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;
+            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");
+        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);
-- 
1.7.4.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to