On 7/30/11 3:50 PM, Simone Marzola wrote:
From: simock85<[email protected]>
added -f option to declare the output format
---
libavformat/output-example.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/libavformat/output-example.c b/libavformat/output-example.c
index 6c604c2..e3c01fa 100644
--- a/libavformat/output-example.c
+++ b/libavformat/output-example.c
@@ -453,12 +453,13 @@ int main(int argc, char **argv)
int framerate;
int tot_frames;
int i;
+ int fmt_flag;
/* initialize libavcodec, and register all codecs and formats */
av_register_all();
if (argc< 2) {
- printf("usage: %s [-d stream_duration] [-r frame_rate] output_file\n"
+ printf("usage: %s [-d stream_duration] [-r frame_rate] [-f format]
output_file\n"
"API example program to output a media file with
libavformat.\n"
"The output format is automatically guessed according to the file
extension.\n"
"Raw images can also be output by using '%%d' in the
filename\n"
@@ -468,12 +469,17 @@ int main(int argc, char **argv)
duration = STREAM_DURATION;
framerate = STREAM_FRAME_RATE;
+ fmt_flag = 0;
- while ((opt = getopt(argc, argv, "d:r:")) != -1) {
+ while ((opt = getopt(argc, argv, "d:f:r:")) != -1) {
switch(opt) {
case 'd':
duration = atof(optarg);
break;
+ case 'f':
+ fmt = av_guess_format(optarg, NULL, NULL);
+ fmt_flag = 1;
This is unnecessary. fmt is either NULL or set, so you can use it
instead of fmt_flag.
+ break;
case 'r':
framerate = atoi(optarg);
break;
@@ -485,7 +491,11 @@ int main(int argc, char **argv)
/* auto detect the output format from the name. default is
mpeg. */
- fmt = av_guess_format(NULL, filename, NULL);
+
+ if (fmt_flag == 0) {
+ printf("Trying to deduce output format from file extension: using
MPEG.\n");
The message is wrong you aren't using MPEG but the format. You might
print which format and which codecs will be used though.
+ fmt = av_guess_format(NULL, filename, NULL);
+ }
if (!fmt) {
printf("Could not deduce output format from file extension: using
MPEG.\n");
fmt = av_guess_format("mpeg", NULL, NULL);
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel