[xiph-commits] r9263 - trunk/ffmpeg2theora

j at motherfish-iii.xiph.org j at motherfish-iii.xiph.org
Tue May 10 13:55:47 PDT 2005


Author: j
Date: 2005-05-10 13:55:44 -0700 (Tue, 10 May 2005)
New Revision: 9263

Modified:
   trunk/ffmpeg2theora/configure.ac
   trunk/ffmpeg2theora/ffmpeg2theora.c
   trunk/ffmpeg2theora/theorautils.h
Log:
make A/V Sync based on input container optional, sinc it does not allways work


Property changes on: trunk/ffmpeg2theora/configure.ac
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/ffmpeg2theora/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.c	2005-05-10 20:54:07 UTC (rev 9262)
+++ trunk/ffmpeg2theora/ffmpeg2theora.c	2005-05-10 20:55:44 UTC (rev 9263)
@@ -98,6 +98,7 @@
         this->sharpness=2;
         this->keyint=64;
         this->force_input_fps=0;
+        this->sync=0;
         this->aspect_numerator=0;
         this->aspect_denominator=0;
         this->frame_aspect=0;
@@ -440,24 +441,27 @@
                                         frame,&got_picture, ptr, len))>0) {
                                         
                         if(got_picture){
-                            double delta = ((double) pkt.dts / 
-                                AV_TIME_BASE - this->pts_offset) * 
-                                this->fps - this->frame_count;
-                            /* 0.7 is an arbitrary value */
-                            /* it should be larger than half a frame to 
-                             avoid excessive dropping and duplicating */
-                            if (delta < -0.7) {
-                                fprintf(stderr,
-                                      "Frame dropped to maintain sync\n");
-                                break;
+                            // this is disabled by default since it does not work
+                            // for all input formats the way it should.
+                            if(this->sync == 1) {
+                                double delta = ((double) pkt.dts / 
+                                    AV_TIME_BASE - this->pts_offset) * 
+                                    this->fps - this->frame_count;
+                                /* 0.7 is an arbitrary value */
+                                /* it should be larger than half a frame to 
+                                 avoid excessive dropping and duplicating */
+                                if (delta < -0.7) {
+                                    fprintf(stderr,
+                                          "Frame dropped to maintain sync\n");
+                                    break;
+                                }
+                                if (delta > 0.7) {
+                                    dups = lrintf(delta);
+                                    fprintf(stderr,
+                                      "%d duplicate %s added to maintain sync\n",
+                                      dups, (dups == 1) ? "frame" : "frames");
+                                }
                             }
-                            if (delta > 0.7) {
-                                dups = lrintf(delta);
-                                fprintf(stderr,
-                                  "%d duplicate %s added to maintain sync\n",
-                                  dups, (dups == 1) ? "frame" : "frames");
-                            }
-
                             //For audio only files command line option"-e" will not work
                             //as we don't increment frame_count in audio section.
                             if(venc->pix_fmt != PIX_FMT_YUV420P) {
@@ -668,6 +672,10 @@
         "\t\t\t\t will be deinterlaced\n"
         "\t --format,-f\t\tspecify input format\n"
         "\t --inputfps [fps]\toverride input fps\n"
+        "\t --sync\t\t\tUse A/V Sync from input container.\n"
+        "\t       \t\tsince this does not work with all input format\n"
+        "\t       \t\tyou have to manualy enable it if you have issues\n"
+        "\t       \t\twith A/V sync.\n"
         
         "\nMetadata options:\n"
         "\t --artist\tName of artist (director)\n"
@@ -714,6 +722,7 @@
     static int inputfps_flag=0;
     static int metadata_flag=0;
     static int deinterlace_flag=0;
+    static int sync_flag=0;
     
     AVInputFormat *input_fmt=NULL;
     ff2theora convert = ff2theora_init ();
@@ -746,7 +755,8 @@
       {"inputfps",required_argument,&inputfps_flag,1},
       {"starttime",required_argument,NULL,'s'},
       {"endtime",required_argument,NULL,'e'},
-
+      {"sync",0,&sync_flag,1},
+  
       {"artist",required_argument,&metadata_flag,10},
       {"title",required_argument,&metadata_flag,11},
       {"date",required_argument,&metadata_flag,12},
@@ -771,6 +781,11 @@
         switch(c)
         {
             case 0:
+                if (sync_flag){
+                    convert->sync=1;
+                    sync_flag=0;
+                }
+
                 if (nosound_flag){
                     convert->disable_audio=1;
                     nosound_flag=0;
@@ -1027,6 +1042,10 @@
                 if(convert->disable_audio){
                     fprintf(stderr,"  [audio disabled].\n");
                 }
+                if(convert->sync){
+                    fprintf(stderr,"  Use A/V Sync from input container.\n");
+                }
+
                 convert->pts_offset = 
                     (double) convert->context->start_time / AV_TIME_BASE;
                 ff2theora_output (convert);

Modified: trunk/ffmpeg2theora/theorautils.h
===================================================================
--- trunk/ffmpeg2theora/theorautils.h	2005-05-10 20:54:07 UTC (rev 9262)
+++ trunk/ffmpeg2theora/theorautils.h	2005-05-10 20:55:44 UTC (rev 9263)
@@ -52,6 +52,7 @@
     int keyint;
 
     double force_input_fps;
+    int sync;
     
     /* cropping */
     int frame_topBand;



More information about the commits mailing list