[xiph-commits] r9456 - trunk/ffmpeg2theora

j at motherfish-iii.xiph.org j at motherfish-iii.xiph.org
Wed Jun 15 07:57:28 PDT 2005


Author: j
Date: 2005-06-15 07:57:24 -0700 (Wed, 15 Jun 2005)
New Revision: 9456

Modified:
   trunk/ffmpeg2theora/ffmpeg2theora.c
Log:
- add initial support to read from v4l devices.



Modified: trunk/ffmpeg2theora/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.c	2005-06-15 02:53:30 UTC (rev 9455)
+++ trunk/ffmpeg2theora/ffmpeg2theora.c	2005-06-15 14:57:24 UTC (rev 9456)
@@ -702,6 +702,8 @@
         "\t\t\t\t otherwise only material marked as interlaced \n"
         "\t\t\t\t will be deinterlaced\n"
         "\t --format,-f\t\tspecify input format\n"
+        "\t --v4l   /dev/video0\tread data from v4l device /dev/video0\n"
+        "\t            \t\tyou have to specifiy an output file with -o\n"
         "\t --inputfps [fps]\toverride input fps\n"
         "\t --audiostream streamid\tby default the last audiostream is selected,\n"
         "\t                 \tuse this to select another audio stream\n"
@@ -757,8 +759,11 @@
     static int deinterlace_flag=0;
     static int audiostream_flag=0;
     static int sync_flag=0;
+    static int v4l_flag=0;
     
-    AVInputFormat *input_fmt=NULL;
+    AVInputFormat *input_fmt = NULL;
+    AVFormatParameters *formatParams = NULL;
+
     ff2theora convert = ff2theora_init ();
     av_register_all ();
     
@@ -779,6 +784,7 @@
       {"samplerate",required_argument,NULL,'H'},
       {"channels",required_argument,NULL,'c'},
       {"nosound",0,&nosound_flag,1},
+      {"v4l",required_argument,&v4l_flag,1},
       {"aspect",required_argument,&aspect_flag,1},
       {"v2v-preset",required_argument,NULL,'p'},
       {"nice",required_argument,NULL,'N'},
@@ -825,6 +831,11 @@
                     convert->disable_audio=1;
                     nosound_flag=0;
                 }
+                if (v4l_flag) {
+                    formatParams = malloc(sizeof(AVFormatParameters));
+                    formatParams->device = optarg;
+                    v4l_flag = 0;
+                }
                 if (deinterlace_flag){
                     convert->deinterlace=1;
                     deinterlace_flag=0;
@@ -1036,6 +1047,29 @@
         optind++;
     }
 
+
+    if(formatParams != NULL) {
+        formatParams->channel = 0;
+        formatParams->width = 384;
+        formatParams->height = 288;
+
+        if(convert->picture_width)
+            formatParams->width = convert->picture_width;
+        if(convert->picture_height)
+            formatParams->height = convert->picture_height;
+
+        formatParams->time_base.den = 25;
+        formatParams->time_base.num = 1;
+        if(convert->force_input_fps) {
+            formatParams->time_base.den = convert->force_input_fps * 1000;
+            formatParams->time_base.num = 1000;
+        }
+        formatParams->standard = "pal";        
+
+        input_fmt = av_find_input_format("video4linux");
+        sprintf(inputfile_name,"");
+    }
+
     //FIXME: is using_stdin still neded? is it needed as global variable?
     using_stdin |= !strcmp(inputfile_name, "pipe:" ) ||
                    !strcmp( inputfile_name, "/dev/stdin" );
@@ -1061,8 +1095,8 @@
         exit(1);
     }
 
-    if (av_open_input_file(&convert->context, inputfile_name, input_fmt, 0, NULL) >= 0){
-            if (av_find_stream_info (convert->context) >= 0){
+    if (av_open_input_file(&convert->context, inputfile_name, input_fmt, 0, formatParams) >= 0){
+        if (av_find_stream_info (convert->context) >= 0){
 #ifdef WIN32
                 if(!strcmp(outputfile_name,"-") || !strcmp(outputfile_name,"/dev/stdout")){
                     _setmode(_fileno(stdout), _O_BINARY);



More information about the commits mailing list