[MPlayer-dev-eng] [PATCH] EDL mute for MEncoder

Oded Shimon ods15 at ods15.dyndns.org
Fri May 13 15:15:10 CEST 2005


For obvious reasons, this doesn't work with -oac copy.
Not much else to say. Passed the test I gave it.

- ods15
-------------- next part --------------
Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.282
diff -u -r1.282 mencoder.c
--- mencoder.c	7 May 2005 14:50:14 -0000	1.282
+++ mencoder.c	13 May 2005 13:07:11 -0000
@@ -237,7 +237,9 @@
 static edl_record_ptr edl_records = NULL; ///< EDL entries memory area
 static edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records
 static short edl_muted; ///< Stores whether EDL is currently in muted mode.
+static short mixer_muted; ///< Stores whether MEncoder is currently in muted mode.
 static short edl_seeking; ///< When non-zero, stream is seekable.
+static short edl_muting; ///< When non-zero, stream is mutable.
 static short edl_seek_type; ///< When non-zero, frames are discarded instead of seeking.
 static short edl_skip; ///< -1 OR the value of in_size of an already read frame.
 /** \brief Seeks for EDL
@@ -983,8 +985,9 @@
 #ifdef USE_EDL
 if (edl_records) free_edl(edl_records);
 next_edl_record = edl_records = NULL;
-edl_muted = 0;
+mixer_muted = edl_muted = 0;
 edl_seeking = 1;
+edl_muting = (mux_a->codec != ACODEC_COPY && sh_audio && sh_audio->afilter);
 edl_skip = -1;
 if (edl_filename) {
     next_edl_record = edl_records = edl_parse_file();
@@ -1035,19 +1038,37 @@
                        in the next loop it will jump out of it.
                     */
                     if (next_edl_record->stop_sec > sh_video->pts) break; // we got to the right place.
-                    if (next_edl_record->action == EDL_MUTE) edl_muted = !edl_muted; // toggle mute each time.
+                    if (next_edl_record->action == EDL_MUTE && edl_muting) edl_muted = !edl_muted; // toggle mute each time.
                 }
 
                 /* for a pedantic EDL, that doesn't show even a single
                    frame from the "censored" area, uncomment next line. */
                 goto goto_redo_edl;
             }
-        } else if (next_edl_record->action == EDL_MUTE) {
-            edl_muted = !edl_muted;  // This variable does nothing for now.
+        } else if (next_edl_record->action == EDL_MUTE && edl_muting) {
+            edl_muted = !edl_muted;
             mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_MUTE: [%f]\n", next_edl_record->start_sec );
             next_edl_record=next_edl_record->next;
         }
     }
+    if (mixer_muted != edl_muted) {
+        float db_vals[AF_NCH];
+        int i;
+        mixer_muted = edl_muted;
+        if (edl_muted) for (i = 0; i < AF_NCH; i++) db_vals[i] = -200.;
+        else for (i = 0; i < AF_NCH; i++) db_vals[i] = 0.;
+
+        if (!af_control_any_rev(sh_audio->afilter, AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals)) {
+            mp_msg(MSGT_GLOBAL, MSGL_INFO, MSGTR_InsertingAfVolume);
+            if (!af_add(sh_audio->afilter, "volume") ||
+                !af_control_any_rev(sh_audio->afilter, AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals))
+            {
+                mp_msg(MSGT_GLOBAL, MSGL_ERR, MSGTR_NoVolume);
+                mixer_muted = edl_muted = 0;
+                edl_muting = 0;
+            }
+        }
+    }
 #endif
 
 
@@ -1551,12 +1572,8 @@
 		float tmp = mux_v->timer + next_edl_record->start_sec - demuxer->video->pts;
 		if (timeleft == -1 || timeleft > tmp) {
 			// There's less time in EDL than what we already know
-			if (next_edl_record->action == EDL_SKIP && edl_seeking) {
-				timeleft = tmp;
-			} else if (next_edl_record->action == EDL_MUTE) {
-				//timeleft = next_edl_record->start_sec - demuxer->video->pts;
-				// For the moment (and probably forever) EDL mute doesn't work in MEncoder
-			}
+			if (next_edl_record->action == EDL_SKIP && edl_seeking) timeleft = tmp;
+			if (next_edl_record->action == EDL_MUTE && edl_muting) timeleft = tmp;
 		}
 	}
 #endif


More information about the MPlayer-dev-eng mailing list