[MPlayer-dev-eng] [PATCH] Optionally pad with silence

Tobias Diedrich ranma at tdiedrich.de
Wed Mar 9 19:52:13 CET 2011


Optionally pad with silence.

Allow silence padding for audiostreams that begin after or end before the
video stream.

-------------- next part --------------
Optionally pad with silence.

Allow silence padding for audiostreams that begin after or end before the
video stream.

Index: mplayer-patchset1/cfg-mencoder.h
===================================================================
--- mplayer-patchset1.orig/cfg-mencoder.h	2011-02-18 20:49:54.629569000 +0100
+++ mplayer-patchset1/cfg-mencoder.h	2011-02-18 20:55:18.457966000 +0100
@@ -183,6 +183,10 @@
     {"audio-preload", &audio_preload, CONF_TYPE_FLOAT, CONF_RANGE|CONF_GLOBAL, 0, 2, NULL},
     {"audio-delay",   &audio_delay_fix, CONF_TYPE_FLOAT, CONF_GLOBAL, 0, 0, NULL},
 
+    // insert silence for missing audio frames
+    {"padaudio", &audio_pad, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+    {"nopadaudio", &audio_pad, CONF_TYPE_FLAG, 0, 0, 0, NULL},
+
     {"x", "-x has been removed, use -vf scale=w:h for scaling.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
     {"xsize", "-xsize has been removed, use -vf crop=w:h:x:y for cropping.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 
Index: mplayer-patchset1/mencoder.c
===================================================================
--- mplayer-patchset1.orig/mencoder.c	2011-02-18 20:49:54.600561000 +0100
+++ mplayer-patchset1/mencoder.c	2011-02-18 20:55:18.460999000 +0100
@@ -149,6 +149,7 @@
 static float audio_preload=0.5;
 static float audio_delay_fix=0.0;
 static float audio_delay=0.0;
+static int audio_pad=0;
 static int ignore_start=0;
 static int audio_density=2;
 
@@ -295,8 +296,14 @@
     while(size<total && !at_eof){
 	int len=total-size;
 		if(len>MAX_OUTBURST) len=MAX_OUTBURST;
-		if (mp_decode_audio(sh_audio, len) < 0)
+		if (mp_decode_audio(sh_audio, len) < 0) {
+                    if (audio_pad) {
+                        memset(buffer+size, 0, len);
+                        size = total;
+                        break;
+                    }
                     at_eof = 1;
+                }
 		if(len>sh_audio->a_out_buffer_len) len=sh_audio->a_out_buffer_len;
 		fast_memcpy(buffer+size,sh_audio->a_out_buffer,len);
 		sh_audio->a_out_buffer_len-=len; size+=len;
Index: mplayer-patchset1/DOCS/man/de/mplayer.1
===================================================================
--- mplayer-patchset1.orig/DOCS/man/de/mplayer.1	2011-02-18 20:55:26.013415000 +0100
+++ mplayer-patchset1/DOCS/man/de/mplayer.1	2011-02-18 20:59:26.670401000 +0100
@@ -7873,6 +7873,11 @@
 .PD 1
 .
 .TP
+.B \-padaudio
+Stille einf?gen wenn der Audiostrom nach dem Videostrom anf?ngt oder vor dem
+Videostrom aufh?rt.
+.
+.TP
 .B \-passlogfile <Dateiname>
 Schreibe die Informationen des ersten Durchlaufs anstelle der Standarddatei
 divx2pass.log in die angegebene Datei.
Index: mplayer-patchset1/DOCS/man/en/mplayer.1
===================================================================
--- mplayer-patchset1.orig/DOCS/man/en/mplayer.1	2011-02-18 20:55:23.772570000 +0100
+++ mplayer-patchset1/DOCS/man/en/mplayer.1	2011-02-18 20:57:45.371432000 +0100
@@ -8015,6 +8015,10 @@
 .PD 1
 .
 .TP
+.B \-padaudio
+Pad with silence when the audio stream begins after or ends before the video stream.
+.
+.TP
 .B \-passlogfile <filename>
 Dump first pass information to <filename> instead of the default divx2pass.log
 in two pass encoding mode.


More information about the MPlayer-dev-eng mailing list