From: simock85 <[email protected]>

added -f option to declare the output format
---
 libavformat/output-example.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/output-example.c b/libavformat/output-example.c
index 6c604c2..1ae55eb 100644
--- a/libavformat/output-example.c
+++ b/libavformat/output-example.c
@@ -458,7 +458,7 @@ int main(int argc, char **argv)
     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"
@@ -466,14 +466,18 @@ int main(int argc, char **argv)
         exit(1);
     }
 
+    fmt = NULL;
     duration = STREAM_DURATION;
     framerate = STREAM_FRAME_RATE;
 
-    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);
+            break;
         case 'r':
             framerate = atoi(optarg);
             break;
@@ -485,7 +489,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) {
+        printf("Trying to deduce output format from file extension\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