You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
examples/decoding_encoding: make operation logic more self-evident / predictable
Add a switch which controls which operation to perform. Useful to test only a single feature. Also the new behavior is more self-consistent.
This commit is contained in:
@@ -600,24 +600,33 @@ static void video_decode_example(const char *outfilename, const char *filename)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
const char *filename;
|
const char *output_type;
|
||||||
|
|
||||||
/* register all the codecs */
|
/* register all the codecs */
|
||||||
avcodec_register_all();
|
avcodec_register_all();
|
||||||
|
|
||||||
if (argc <= 1) {
|
if (argc < 2) {
|
||||||
|
printf("usage: %s output_type\n"
|
||||||
|
"API example program to decode/encode a media stream with libavcodec.\n"
|
||||||
|
"output_type must be choosen between 'h264', 'mp2', 'mpg'\n",
|
||||||
|
argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
output_type = argv[1];
|
||||||
|
|
||||||
|
if (!strcmp(output_type, "h264")) {
|
||||||
|
video_encode_example("test.h264", AV_CODEC_ID_H264);
|
||||||
|
} else if (!strcmp(output_type, "mp2")) {
|
||||||
audio_encode_example("test.mp2");
|
audio_encode_example("test.mp2");
|
||||||
audio_decode_example("test.sw", "test.mp2");
|
audio_decode_example("test.sw", "test.mp2");
|
||||||
|
} else if (!strcmp(output_type, "mpg")) {
|
||||||
video_encode_example("test.h264", AV_CODEC_ID_H264);
|
|
||||||
video_encode_example("test.mpg", AV_CODEC_ID_MPEG1VIDEO);
|
video_encode_example("test.mpg", AV_CODEC_ID_MPEG1VIDEO);
|
||||||
filename = "test.mpg";
|
video_decode_example("test%02d.pgm", "test.mpg");
|
||||||
} else {
|
} else {
|
||||||
filename = argv[1];
|
fprintf(stderr, "Invalid output type '%s', choose between 'h264', 'mp2', or 'mpg'\n",
|
||||||
|
output_type);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// audio_decode_example("test.sw", filename);
|
|
||||||
video_decode_example("test%02d.pgm", filename);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user