Browse code

audio drift threshold (this switches between resampling style timestamp drift compensation and hard insert silence / drop samples compensation)

Originally committed as revision 9969 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2007/08/07 09:03:50
Showing 1 changed files
... ...
@@ -178,6 +178,7 @@ static int video_stream_copy = 0;
178 178
 static int subtitle_stream_copy = 0;
179 179
 static int video_sync_method= 1;
180 180
 static int audio_sync_method= 0;
181
+static float audio_drift_threshold= 0.1;
181 182
 static int copy_ts= 0;
182 183
 static int opt_shortest = 0; //
183 184
 static int video_global_header = 0;
... ...
@@ -453,7 +454,7 @@ static void do_audio_out(AVFormatContext *s,
453 453
 
454 454
         //FIXME resample delay
455 455
         if(fabs(delta) > 50){
456
-            if(ist->is_start){
456
+            if(ist->is_start || fabs(delta) > audio_drift_threshold*enc->sample_rate){
457 457
                 if(byte_delta < 0){
458 458
                     byte_delta= FFMAX(byte_delta, -size);
459 459
                     size += byte_delta;
... ...
@@ -3607,6 +3608,7 @@ const OptionDef options[] = {
3607 3607
     { "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
3608 3608
     { "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" },
3609 3609
     { "async", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&audio_sync_method}, "audio sync method", "" },
3610
+    { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&audio_drift_threshold}, "audio drift threshold", "" },
3610 3611
     { "vglobal", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_global_header}, "video global header storage type", "" },
3611 3612
     { "copyts", OPT_BOOL | OPT_EXPERT, {(void*)&copy_ts}, "copy timestamps" },
3612 3613
     { "shortest", OPT_BOOL | OPT_EXPERT, {(void*)&opt_shortest}, "finish encoding within shortest input" }, //