[MPlayer-dev-eng] [PATCH] add framenoopts (rediffed)

Jan Gutter jan at ist.co.za
Thu Jul 1 13:32:53 CEST 2004


So, I dusted off my patch to add -framenoopts to the command-line.

main/DOCS/xml/en/mencoder.xml now has less info about 3-pass encoding.
I'm not sure where exactly to put anything (if at all) about
-framenoopts.

The capitalisation changes in the man file is only to make it consistent
with the critique this patch received, so not really necessary.

dvd2divxscript.pl shows how this patch "cleans" a couple of scripts up.

changed all output to use mp_msg.


-------------- next part --------------
diff -urN main~/DOCS/man/en/mplayer.1 main/DOCS/man/en/mplayer.1
--- main~/DOCS/man/en/mplayer.1	2004-07-01 13:09:42.484495800 +0200
+++ main/DOCS/man/en/mplayer.1	2004-07-01 13:15:33.483135896 +0200
@@ -4207,13 +4207,15 @@
 .PD 0
 .RSs
 .IPs "\-ovc copy"
-no encoding, just streamcopy
+No encoding, just streamcopy.
 .IPs "\-ovc divx4"
-encode to DivX4/\:DivX5
+Encode to DivX4/\:DivX5.
 .IPs "\-ovc raw"
-encode to arbitrary uncompressed format (use \-vf format to select)
+Encode to arbitrary uncompressed format (use \-vf format to select).
 .IPs "\-ovc lavc"
-encode with a libavcodec codecs
+Encode with a libavcodec codec.
+.IPs "\-ovc frameno"
+A pseudo-codec used in three-pass encoding to calculate bitrates.
 .RE
 .PD 1
 .
@@ -5397,6 +5399,27 @@
 .B rtjpeg\ 
 Enable rtjpeg encoding.
 .
+.SS frameno (\-framenoopts)
+.
+The frameno pseudo-codec is used to calculate the required bitrate for a 
+two-pass encoding session more precisely.
+In order to to this, only the audio is compressed.
+After the size of the compressed audio is subtracted from the target size, 
+a much more accurate guess can be made for the target bitrate.
+.br
+.I NOTE:
+Three-pass encoding is documented much more thoroughly in the mencoder
+documentation.
+You are encouraged to consult it.
+.TP
+.B cdsize=<0\-32000>
+The default target size is 700MB.
+Using this option, the target size in MB may be specified.
+.TP
+.B filename=<filename> 
+The default file name to be used is frameno.avi. 
+Using this option, another output for the dummy file can be specified.
+.
 .SS xvidenc (\-xvidencopts)
 .
 There are three modes available: constant bitrate (CBR), fixed quantizer and
diff -urN main~/TOOLS/dvd2divxscript.pl main/TOOLS/dvd2divxscript.pl
--- main~/TOOLS/dvd2divxscript.pl	2004-07-01 13:10:14.322655664 +0200
+++ main/TOOLS/dvd2divxscript.pl	2004-07-01 13:15:33.486135440 +0200
@@ -132,19 +132,11 @@
 	exit;
 }
 
-if ($cdsize == 650) {}
-elsif ($cdsize == 700) {}
-elsif ($cdsize == 800) {}
-elsif ($cdsize == 0 ) {
+if ($cdsize == 0 ) {
 	print "No CD Size Specified - Setting to Default Value\n";
 	$cdsize = $cdsize_default;
 }
 
-else	{
-print "CD Size not valid. please choose [650|700|800]\n";
-exit;
-}
-
 if ($output eq "") {
 	print "No MovieName given - You must specify one with: --out [movie_name]\n";
 	exit;
@@ -209,7 +201,7 @@
 die "Prechacheing failed. mencoder exited with Status Code $?" unless $status == 0;
 
 print "Encoding Audio...\n";
-$status = system ("mencoder $vob_tempfile -ovc frameno -oac mp3lame -lameopts br=$abr:cbr:vol=3 -o frameno.avi 1>./audio.stderr 2>/dev/tty8");
+$status = system ("mencoder $vob_tempfile -ovc frameno -framenoopts cdsize=$cdsize -oac mp3lame -lameopts br=$abr:cbr:vol=3 -o frameno.avi 1>./audio.stderr 2>/dev/tty8");
 die "Encoding Audio failed. mencoder exited with Status Code $?" unless $status == 0;
 
 # now we have to find out the recommended bitrate for the Video encoding process...
diff -urN main~/cfg-mencoder.h main/cfg-mencoder.h
--- main~/cfg-mencoder.h	2004-07-01 13:09:15.962527752 +0200
+++ main/cfg-mencoder.h	2004-07-01 13:15:33.487135288 +0200
@@ -65,6 +65,8 @@
 
 extern m_option_t nuvopts_conf[];
 
+extern m_option_t framenoopts_conf[];
+
 m_option_t ovc_conf[]={
 	{"copy", &out_video_codec, CONF_TYPE_FLAG, 0, 0, VCODEC_COPY, NULL},
 	{"frameno", &out_video_codec, CONF_TYPE_FLAG, 0, 0, VCODEC_FRAMENO, NULL},
@@ -242,6 +244,8 @@
 
 	{"nuvopts",  nuvopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
 
+	{"framenoopts",  framenoopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+	
 #define MAIN_CONF
 #include "cfg-common.h"
 #undef MAIN_CONF
diff -urN main~/help/help_mp-en.h main/help/help_mp-en.h
--- main~/help/help_mp-en.h	2004-07-01 13:10:18.153073352 +0200
+++ main/help/help_mp-en.h	2004-07-01 13:15:33.488135136 +0200
@@ -179,7 +179,8 @@
 #define MSGTR_ErrorWritingFile "%s: Error writing file.\n"
 #define MSGTR_WritingAVIIndex "\nWriting AVI index...\n"
 #define MSGTR_FixupAVIHeader "Fixing AVI header...\n"
-#define MSGTR_RecommendedVideoBitrate "Recommended video bitrate for %s CD: %d\n"
+#define MSGTR_RecommendedVideoBitrate "Recommended video bitrate for %dMB CD: %d\n"
+#define MSGTR_FramenoOptsIsAvailable "Use -framenoopts cdsize=<size in MB> to specify size.\n"
 #define MSGTR_VideoStreamResult "\nVideo stream: %8.3f kbit/s  (%d bps)  size: %d bytes  %5.3f secs  %d frames\n"
 #define MSGTR_AudioStreamResult "\nAudio stream: %8.3f kbit/s  (%d bps)  size: %d bytes  %5.3f secs\n"
 
diff -urN main~/mencoder.c main/mencoder.c
--- main~/mencoder.c	2004-07-01 13:09:22.889474696 +0200
+++ main/mencoder.c	2004-07-01 13:15:33.504132704 +0200
@@ -236,6 +236,16 @@
 #endif
 #endif
 
+// frameno "codec" options
+unsigned int frameno_cdsize = 0; // Default behavior -- print old output
+char* frameno_filename = "frameno.avi"; // use frameno.avi
+
+m_option_t framenoopts_conf[]={
+  {"filename", &frameno_filename, CONF_TYPE_STRING, 0, 0, 0, NULL},
+  {"cdsize", &frameno_cdsize, CONF_TYPE_INT, M_OPT_RANGE, 0, 32000, NULL},
+  {NULL, NULL, 0, 0, 0, 0, NULL}
+};
+
 //static int vo_w=0, vo_h=0;
 
 //-------------------------- config stuff:
@@ -371,7 +381,6 @@
 
 m_entry_t* filelist = NULL;
 char* filename=NULL;
-char* frameno_filename="frameno.avi";
 
 int decoded_frameno=0;
 int next_frameno=-1;
@@ -434,7 +443,7 @@
   stream2=open_stream(frameno_filename,0,&i);
   if(stream2){
     demuxer2=demux_open(stream2,DEMUXER_TYPE_AVI,-1,-1,-2,NULL);
-    if(demuxer2) printf(MSGTR_UsingPass3ControllFile,frameno_filename);
+    if(demuxer2) mp_msg(MSGT_DEMUXER,MSGL_STATUS,MSGTR_UsingPass3ControllFile,frameno_filename);
     else mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);
   }
 
@@ -1503,12 +1512,13 @@
     vobsub_out_close(vobsub_writer);
 
 if(out_video_codec==VCODEC_FRAMENO && mux_v->timer>100){
-    printf(MSGTR_RecommendedVideoBitrate,"650MB",(int)((650*1024*1024-muxer_f_size)/mux_v->timer/125));
-    printf(MSGTR_RecommendedVideoBitrate,"700MB",(int)((700*1024*1024-muxer_f_size)/mux_v->timer/125));
-    printf(MSGTR_RecommendedVideoBitrate,"800MB",(int)((800*1024*1024-muxer_f_size)/mux_v->timer/125));
-    printf(MSGTR_RecommendedVideoBitrate,"2 x 650MB",(int)((2*650*1024*1024-muxer_f_size)/mux_v->timer/125));
-    printf(MSGTR_RecommendedVideoBitrate,"2 x 700MB",(int)((2*700*1024*1024-muxer_f_size)/mux_v->timer/125));
-    printf(MSGTR_RecommendedVideoBitrate,"2 x 800MB",(int)((2*800*1024*1024-muxer_f_size)/mux_v->timer/125));
+    if(frameno_cdsize==0){
+        mp_msg(MSGT_MENCODER,MSGL_STATUS,MSGTR_RecommendedVideoBitrate,700,(int)((700*1024*1024-muxer_f_size)/mux_v->timer/125));
+        mp_msg(MSGT_MENCODER,MSGL_STATUS,MSGTR_FramenoOptsIsAvailable);
+    } 
+    else {
+        mp_msg(MSGT_MENCODER,MSGL_STATUS,MSGTR_RecommendedVideoBitrate,frameno_cdsize,(int)((frameno_cdsize*1024*1024-muxer_f_size)/mux_v->timer/125));
+    }
 }
 
 printf(MSGTR_VideoStreamResult,


More information about the MPlayer-dev-eng mailing list