[xiph-commits] r14969 - in trunk/ffmpeg2theora: . src

j at svn.xiph.org j at svn.xiph.org
Tue May 27 13:59:13 PDT 2008


Author: j
Date: 2008-05-27 13:59:13 -0700 (Tue, 27 May 2008)
New Revision: 14969

Modified:
   trunk/ffmpeg2theora/
   trunk/ffmpeg2theora/ffmpeg2theora.1
   trunk/ffmpeg2theora/src/ffmpeg2theora.c
   trunk/ffmpeg2theora/src/ffmpeg2theora.h
Log:
 * fix --inputfps for image sequences, -f image 2 no longer required
 * re-enable v4l/v4l2 input, works via -f video4linux now



Property changes on: trunk/ffmpeg2theora
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2008-05-27 12:13:41.647000074 +0200
committer: j
properties: 
	branch-nick: ffmpeg2theora

   + timestamp: 2008-05-27 22:55:56.706000090 +0200
committer: j
properties: 
	branch-nick: ffmpeg2theora

Name: bzr:revision-id:v3-single1-dHJ1bmsvZmZtcGVnMnRoZW9yYQ..
   - 191 j-20080517230830-he5x8v2m8yrfiw35
192 j-20080518224037-pkmoctzf4qce7tog
193 j-20080518224409-6hbfp3k2ssn6egqa
194 j-20080520111939-dhi52qwbqe7a47cu
195 j-20080523092252-gj9k9db0s67vl7dw
196 j-20080523092420-l0850yrq1qkgz9t0
197 j-20080523093057-l5g0ezzy5geu0pey
198 j-20080523094343-kcno1dm2e1lr38q4
199 j-20080523163006-kjl6ewea5sxawmq2
200 j-20080523165904-l2vm52qae0hlqkhp
201 j-20080523175432-2ed953iktnl8c7cr
202 j-20080525100939-7oja8pk08v9fquiw
203 j-20080526111321-nhzaqh6ivzn0vs7b
204 j-20080527100851-2v5eyxxrq1riqi50
205 j-20080527101341-9ynbgth2b15jw792

   + 191 j-20080517230830-he5x8v2m8yrfiw35
192 j-20080518224037-pkmoctzf4qce7tog
193 j-20080518224409-6hbfp3k2ssn6egqa
194 j-20080520111939-dhi52qwbqe7a47cu
195 j-20080523092252-gj9k9db0s67vl7dw
196 j-20080523092420-l0850yrq1qkgz9t0
197 j-20080523093057-l5g0ezzy5geu0pey
198 j-20080523094343-kcno1dm2e1lr38q4
199 j-20080523163006-kjl6ewea5sxawmq2
200 j-20080523165904-l2vm52qae0hlqkhp
201 j-20080523175432-2ed953iktnl8c7cr
202 j-20080525100939-7oja8pk08v9fquiw
203 j-20080526111321-nhzaqh6ivzn0vs7b
204 j-20080527100851-2v5eyxxrq1riqi50
205 j-20080527101341-9ynbgth2b15jw792
206 j-20080527205556-19tffvfrxgt3khld


Modified: trunk/ffmpeg2theora/ffmpeg2theora.1
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.1	2008-05-27 14:42:42 UTC (rev 14968)
+++ trunk/ffmpeg2theora/ffmpeg2theora.1	2008-05-27 20:59:13 UTC (rev 14969)
@@ -209,10 +209,10 @@
   cat something.dv | ffmpeg2theora -f dv -o output.ogv \-
 
 Encode a series of images:
-  ffmpeg2theora -f image2 frame%06d.png -o output.ogv
+  ffmpeg2theora frame%06d.png -o output.ogv
 
 Live streaming from V4L Device:
-  ffmpeg2theora \-\-v4l /dev/video0 \-\-inputfps 15 \-x 160 \-y 128 \-o \- \\
+  ffmpeg2theora /dev/video0 \-\-inputfps 15 \-x 160 \-y 128 \-o \- \\
     | oggfwd iccast2server 8000 password /theora.ogv
 
 Live encoding from a DV camcorder (needs a fast machine):

Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c	2008-05-27 14:42:42 UTC (rev 14968)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c	2008-05-27 20:59:13 UTC (rev 14969)
@@ -44,10 +44,6 @@
 #include "subtitles.h"
 #include "ffmpeg2theora.h"
 
-#ifdef __linux__
-  #define VIDEO4LINUX_ENABLED
-#endif
-
 enum {
   NULL_FLAG,
   DEINTERLACE_FLAG,
@@ -159,7 +155,8 @@
         this->video_bitrate=0;
         this->sharpness=0;
         this->keyint=64;
-        this->force_input_fps=0;
+        this->force_input_fps.num = -1;
+        this->force_input_fps.den = 1;
         this->sync=0;
         this->aspect_numerator=0;
         this->aspect_denominator=0;
@@ -339,8 +336,8 @@
         if (fps > 10000)
             fps /= 1000;
 
-        if(this->force_input_fps)
-            fps=this->force_input_fps;
+        if(this->force_input_fps.num > 0)
+            fps=(double)this->force_input_fps.num / this->force_input_fps.den;
         if (vcodec == NULL || avcodec_open (venc, vcodec) < 0) {
             this->video_index = -1;
         }
@@ -549,9 +546,9 @@
 
         lut_init(this);
     }
-    if (this->framerate_new.num > 0) {
+    if (this->framerate_new.num > 0 && this->fps != (double)this->framerate_new.num / this->framerate_new.den) {
         fprintf(stderr,"  Resample Framerate: %0.2f => %0.2f\n",
-                        this->fps,(double)this->framerate_new.num / this->framerate_new.den);
+                        this->fps, (double)this->framerate_new.num / this->framerate_new.den);
     }
     if (this->audio_index >= 0){
         astream = this->context->streams[this->audio_index];
@@ -647,23 +644,16 @@
             info.ti.frame_height = this->picture_height;
             info.ti.offset_x = this->frame_x_offset;
             info.ti.offset_y = this->frame_y_offset;
-            if(this->force_input_fps) {
-                info.ti.fps_numerator = 1000000 * (this->fps);    /* fps= numerator/denominator */
-                info.ti.fps_denominator = 1000000;
+            if (this->framerate_new.num > 0) {
+                // new framerate is interger only right now,
+                // so denominator is always 1
+                info.ti.fps_numerator = this->framerate_new.num;
+                info.ti.fps_denominator = this->framerate_new.den;
             }
             else {
-                if (this->framerate_new.num > 0) {
-                    // new framerate is interger only right now,
-                    // so denominator is always 1
-                    info.ti.fps_numerator = this->framerate_new.num;
-                    info.ti.fps_denominator = this->framerate_new.den;
-                }
-                else {
-                    info.ti.fps_numerator=vstream->r_frame_rate.num;
-                    info.ti.fps_denominator = vstream->r_frame_rate.den;
-                }
+                info.ti.fps_numerator=vstream->r_frame_rate.num;
+                info.ti.fps_denominator = vstream->r_frame_rate.den;
             }
-
             /* this is pixel aspect ratio */
             info.ti.aspect_numerator=this->aspect_numerator;
             info.ti.aspect_denominator=this->aspect_denominator;
@@ -704,9 +694,9 @@
             if (ks->num_subtitles > 0) {
                 kate_info_set_language(ki, ks->subtitles_language);
                 kate_info_set_category(ki, ks->subtitles_category[0]?ks->subtitles_category:"subtitles");
-                if(this->force_input_fps) {
-                    ki->gps_numerator = 1000000 * (this->fps);    /* fps= numerator/denominator */
-                    ki->gps_denominator = 1000000;
+                if(this->force_input_fps.num > 0) {
+                    ki->gps_numerator = this->force_input_fps.num;    /* fps= numerator/denominator */
+                    ki->gps_denominator = this->force_input_fps.den;
                 }
                 else {
                     if (this->framerate_new.num > 0) {
@@ -1216,14 +1206,12 @@
         "  cat something.dv | ffmpeg2theora -f dv -o output.ogv -\n"
         "\n"
         "  Encode a series of images:\n"
-        "    ffmpeg2theora -f image2 frame%%06d.png -o output.ogv\n"
+        "    ffmpeg2theora frame%%06d.png -o output.ogv\n"
         "\n"
-#if 0
         "  Live streaming from V4L Device:\n"
-        "    ffmpeg2theora  /dev/video0 -fps 15 -x 160 -y 128 -o - \\\n"
+        "    ffmpeg2theora /dev/video0 -fps 15 -x 160 -y 128 -o - \\\n"
         "     | oggfwd iccast2server 8000 password /theora.ogv\n"
         "\n"
-#endif
         "  Live encoding from a DV camcorder (needs a fast machine):\n"
         "    dvgrab - | ffmpeg2theora -f dv -x 352 -y 288 -o output.ogv -\n"
         "\n"
@@ -1247,7 +1235,7 @@
     static int metadata_flag = 0;
 
     AVInputFormat *input_fmt = NULL;
-    AVFormatParameters *formatParams = NULL;
+    AVFormatParameters params, *formatParams = &params;
 
     int c,long_option_index;
     const char *optstring = "P:o:k:f:F:x:y:v:V:a:A:S:K:d:H:c:G:Z:C:B:p:N:s:e:D:h::";
@@ -1392,7 +1380,7 @@
                             flag = -1;
                             break;
                         case INPUTFPS_FLAG:
-                            convert->force_input_fps = atof(optarg);
+                            convert->force_input_fps = get_framerate(optarg);
                             flag = -1;
                             break;
                         case AUDIOSTREAM_FLAG:
@@ -1664,30 +1652,6 @@
         optind++;
     }
 
-#ifdef VIDEO4LINUX_ENABLED
-    if(formatParams != NULL) {
-        formatParams->channel = 0;
-        formatParams->width = PAL_HALF_WIDTH;
-        formatParams->height = PAL_HALF_HEIGHT;
-        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,"");
-    }
-#endif
-
     //FIXME: is using_stdin still neded? is it needed as global variable?
     using_stdin |= !strcmp(inputfile_name, "pipe:" ) ||
                    !strcmp( inputfile_name, "/dev/stdin" );
@@ -1728,7 +1692,34 @@
           ks->subtitles = NULL;
         }
     }
-
+    //detect image sequences and set framerate if provided
+    fprintf(stderr, "test, %d\n", strcmp(input_fmt->name, "video4linux"));
+    if(av_guess_image2_codec(inputfile_name) != CODEC_ID_NONE || \
+       (input_fmt != NULL && strcmp(input_fmt->name, "video4linux") >= 0)) {
+        memset(formatParams, 0, sizeof(*formatParams));
+        if(convert->force_input_fps.num > 0) {
+            formatParams->time_base.den = convert->force_input_fps.num;
+            formatParams->time_base.num = convert->force_input_fps.den;
+        }
+        if(input_fmt != NULL && strcmp(input_fmt->name, "video4linux") >= 0) {
+            formatParams->channel = 0;
+            formatParams->width = PAL_HALF_WIDTH;
+            formatParams->height = PAL_HALF_HEIGHT;
+            formatParams->time_base.den = 25;
+            formatParams->time_base.num = 2;
+            if(convert->picture_width)
+                formatParams->width = convert->picture_width;
+            if(convert->picture_height)
+                formatParams->height = convert->picture_height;
+        }
+        fprintf(stderr, "height: %d\n", formatParams->height);
+        fprintf(stderr, "width: %d\n", formatParams->width);
+        if(convert->force_input_fps.num > 0) {
+            formatParams->time_base.den = convert->force_input_fps.num;
+            formatParams->time_base.num = convert->force_input_fps.den;
+        }
+        formatParams->video_codec_id = av_guess_image2_codec(inputfile_name);
+    }
     if (av_open_input_file(&convert->context, inputfile_name, input_fmt, 0, formatParams) >= 0){
         if (av_find_stream_info (convert->context) >= 0){
 #ifdef WIN32

Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.h
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.h	2008-05-27 14:42:42 UTC (rev 14968)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.h	2008-05-27 20:59:13 UTC (rev 14969)
@@ -59,7 +59,7 @@
     int keyint;
     char pp_mode[255];
 
-    double force_input_fps;
+    AVRational force_input_fps;
     int sync;
 
     /* cropping */



More information about the commits mailing list