[MPlayer-dev-eng] [PATCH] add framenoopts

Jan Gutter jan at ist.co.za
Thu May 6 18:31:29 CEST 2004


Next version of the -framenoopts patch. The difference between this one
and the previous version is the use of mp_msg in stead of printf.

Also, note how TOOLS/dvd2divxscript.pl changed (for the better, I hope)
in order to utilize the new option.

Please CC me in all correspondence. My work's spam filter believes that
the mplayer list is a breeding ground of hackers and pornographers.

On a related topic: any tips on submitting patches with Evolution 1.4.6?

-------------- next part --------------
diff -urN main~/DOCS/man/en/mplayer.1 main/DOCS/man/en/mplayer.1
--- main~/DOCS/man/en/mplayer.1	2004-05-06 18:04:14.829670320 +0200
+++ main/DOCS/man/en/mplayer.1	2004-05-06 18:05:03.666246032 +0200
@@ -4036,13 +4036,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
 .
@@ -5219,6 +5221,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~/DOCS/xml/en/mencoder.xml main/DOCS/xml/en/mencoder.xml
--- main~/DOCS/xml/en/mencoder.xml	2004-05-03 16:13:53.000000000 +0200
+++ main/DOCS/xml/en/mencoder.xml	2004-05-06 18:05:03.667245880 +0200
@@ -69,6 +69,11 @@
   long movie, <application>MEncoder</application> prints the recommended
   bitrate values for 650Mb, 700Mb, and 800Mb destination sizes, after this
   pass finishes.
+  </para>
+  <para>
+  If a custom CD size is needed, use the
+  <option>-framenoopts cdsize=<replaceable>size in Mb</replaceable></option>
+  option to specify the destination size for the bitrate calculation, in Mb.
   </para></step>
 <step><para>
   <emphasis>Second pass:</emphasis>
diff -urN main~/TOOLS/dvd2divxscript.pl main/TOOLS/dvd2divxscript.pl
--- main~/TOOLS/dvd2divxscript.pl	2004-05-03 16:13:54.000000000 +0200
+++ main/TOOLS/dvd2divxscript.pl	2004-05-06 18:05:03.668245728 +0200
@@ -128,19 +128,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;
@@ -205,7 +197,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-05-03 16:13:54.000000000 +0200
+++ main/cfg-mencoder.h	2004-05-06 18:05:03.668245728 +0200
@@ -61,6 +61,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},
@@ -238,6 +240,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-05-03 16:13:53.000000000 +0200
+++ main/help/help_mp-en.h	2004-05-06 18:05:03.669245576 +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-05-03 16:13:56.000000000 +0200
+++ main/mencoder.c	2004-05-06 18:05:03.670245424 +0200
@@ -233,6 +233,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:
@@ -368,7 +378,6 @@
 
 m_entry_t* filelist = NULL;
 char* filename=NULL;
-char* frameno_filename="frameno.avi";
 
 int decoded_frameno=0;
 int next_frameno=-1;
@@ -431,7 +440,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);
   }
 
@@ -1497,12 +1506,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