mjpegtools.1
来自「Motion JPEG编解码器源代码」· 1 代码 · 共 2,296 行 · 第 1/5 页
1
2,296 行
.IP "-P".nr bi 1.PPThis ensures that 2 B frames appear between adjacent I/Pframes. Several common MPEG-1 decoders can't handle streams that do nothave 2 B-frames between I/P frames.IP "-g 6 -G 20".nr bi 1.PPthe encoder can dynamically change thegroup-of-pictures size to reflect scene changes. This is done by setting amaximum GOP (-G flag) size larger than the minimum (-g flag). For VCDs sensible values might be a minimum of 9 and a maximum of 15.For SVCD 9 and 15 would be good values. If you only want to play it back on SW player you can use other min-max values..if \n(ll>1 .RE.nr ll -1.PP.PPExample.PP\fB> lav2yuv stream*.avi \(br mpeg2enc -b 1500 -r 16 -4 1 -2 1-S 630 -B 260 -o video_n1_1500_r16_41_21_S630_B240.m1v\fP.PPlav2yuv processes all the stream files. Then mpeg2enc is given someoptions that make the encoded stream look nicer. Using\fB-S 630\fP means that mpeg2enc marks the stream so that mplexgenerates a new stream every 630MB. One important thing is the use ofthe \fB-B\fP option which specifies the non-video (audio and mplexinformation) bitrate. The \fB-B\fP value of 260 should be fine for audio with 224kBit and mplex information. For further information take a look at the encoding scripts in the scripts directory..PP.PPMPEG1 Multiplexing Example.PPExample.PP\fB >mplex sound.mp2 video.m1v -o my_video.mpg\fP.PPPuts the sound.mp2 and the video.m1v stream together to my_video.mpg.It only works that easy if you have CBR (the -q option was not used withmpeg2enc)..PPExample.PP\fBmplex -V -r 1740 audio.mp2 video_vbr.m1v -o vbr_stream.mpg\fP.PPHere we multiplex a variable bitrate stream. mplex is now a singlepass multiplexer so it can't detect the maximal bitrate and we have tospecify it. The data rate for the output stream is: \fBaudio bitrate +peak videobitrate + 1-2% for mplex information\fP\&. If audio (-b 224)has 224kBit, video has 1500kBit (was encoded with -b 1500 -q 9) then we have 1724 * 1.01 or about 1740kBit..PP.SH Creating MPEG2 Videos.PPMPEG2 is recommended for sources with a greater picture than 352x240for NTSC and 352x288 for PAL. MPEG2 can also handle interlaced sourceslike recording from TV at full resolution..PPMPEG2 allows the usage of mpeg layer 3 (mp3) sound. So you can use your favorite mp3encoder for the creation of the sound. However, MP3 audio is not valid for DVDs. It is best to use MP2 (Layer 2) audio. The audio can also be a VBR Stream..PPMPEG2 is usually a VBR Stream. MPEG2 creation with optimization requires alot of CPU power. A film with the double resolution is NOT4 times larger than an MPEG1 Stream. Depending on your qualitysettings it will be about 1.5 up to 3 times larger than the MPEG1Stream at its lower resolution..PPMPEG2 Audio creation Example.PP\fB> lav2wav editlist.eli \(br mp2enc -o sound.mp2\fP.PPThis will fit the MPEG2 quite well. You can save some bits by tellingmp2enc to use a lower bitrate (-b option) like 160 or 192 kBit/s. And mightwant to add -r 44100 so that mpeg2enc generates a 44.1kHz sampling rate audiofile. I hope I don't need to explain the usage of an MP3 Encoder.But you should not use all the fancy options that are available..PPMPEG2 Video creation Example.PP\fB> lav2yuv editlist.eli \(br mpeg2enc -f 3 -b 3000 -q 9-o video.m2v\fP.PPA very simple example for MPEG2 Video.The most important option is the -f 3. That tells mpeg2enc that itshould create a MPEG2 stream. Because it is a generic MPEG2 you haveto use the -b bitrate options. And should use the -q option becauseyou usually want a space saving VBR Stream. When using VBR streams the-b option tells mpeg2enc the maximum bitrate that can be used. The -q option tell mpeg2enc what quality the streams should have. The bitrate hasan upper bound of the value specified by -b..PP\fB> lav2yuv editlist.eli \(br mpeg2enc -f 3 -4 1 -2 1 -q7 -b 4500-V 300 -P -g 6 -G 18 -I 1 -o video.m2v\fP.PPThis will generate a higher quality MPEG2 stream because the -4 1 and-2 1 options were used. With -b 4500 -q 7 you tell mpeg2enc the maximal bitrate and the quality factor. -V is the video buffer sizeused for decoding the stream. For SW playback it can be much higherthan the default. Dynamic GOP is set with -g and -G. A larger GOP size canhelp reduce the bit-rate required for a given quality but very large sizescan introduce artifacts due to DCT/iDCT accumulated rounding errors.The -P optionalso ensures that 2 B frames appear between adjacent I/P frames. The-I 1 option tells mpeg2enc that the source is a interlaced materiallike videos. There is (time consuming) interlaced motioncompensation logic present in mpeg2enc. Mpeg2enc will use that logicif the size of the frames you encode is larger than the VCD size for your TV Norm..PPIf you denoise the images with yuvdenoise and use the deinterlacing (-F) option you should tell mpeg2enc that it does not need to do motion estimation for interlaced material. You have to use the -I 0option of mpeg2enc to say that the frames are already deinterlaced.This will save a lot of time when encoding. If you don't use -I 0 it willnot cause problems, the encoding will just take longer..PPYou can also use scaling an options that optimize (denoise) the images to get smaller streams. These options are explained in detailin the following sections.Which values should be used for VBR Encoding.PPThe -q option controls the minimum quantization of the output stream.Quantization controls the precision with which image information isencoded. The lower the value the better the image quality. Values below 4are extremes and should only be used if you know what you are doing.PPUsually you have to set up a maximum bitrate with the -b option.The tricky task is to set a value for the -q option and the -b optionthat produces a nice movie without using too much bandwidth and does not introduce too many artifacts..PPA quality factor should be chosen that way that the mplex output ofPeak bit-rate and average bit-rate differ by about 20-25%\&.If the difference is very small (less than < 10%) it is likelythat you will begin to see artifacts in high motion scenes. The most commoncause of the average rate being too close (or equal) to the maximum rateis wrong value for the maximal bitrate or a quality factor that is too high..PPA combination that will produce more artifacts than you can count is a SVCD with a maximal video bitrate of 2500kBit and a qualitfactor setto 1 or 2.For SVCD with a video limit of 2500kBit a quality factor of 7-11 fitsquite good (8 is the default). If you use filter programs or have a very good source like digital TV, DVD like material or rendered pictures you canuse a quality factor of 6 when creating SVCDs. If your SVCD/DVDplayer supports higher bitrates than the official 2788kBit/sec for thevideo and audio. When using a higher bitrate and quality factoraction scenes will look much better but of course the playing time of thedisc will be less..PPThe same (7-11) quality factor for a full size picture and a topbitrate of 3500 to 4000 kBit will produce few artifacts..PPFor SVCD/DVD you can expect a result like the one described if themaximal bitrate is not set too low:.PP.DS.sp .ft RR.nf q <= 6 real sharp pictures, and good quality q <= 8 good quality q >= 10 average quality q >= 11 not that good q >= 13 here even still sequences might look blocky.DE.fi .ec.ft P.spEncoding destination TV (interlaced) or Monitor (progressive).PPMPEG2 supports interlaced data in addition to the progressive format. A MPEG2 movie can be interlaced or progressive. It depends on the source (film or broadcast) and on the viewing device..PPIf you encode a film both fields should be the same. Deinterlace thestream with yuvdenoise -F, or if you have a high quality source, and don't need to use the denoiser, with yuvcorrect -T NOT_INTERLACED. Alsoset the mpeg2enc interlace-mode (-I) option to 0. This means thatthere is no interlacing.We do not really need deinterlacing here because there is no motion between the fields of the frame. We only need to unite the two fields into asingle progressive frame..PPThis movie should play back an any device (TV or Monitor) withoutproblems..PPIf you have an interlaced source (broadcast) you can encode it as interlaced stream. Or deinterlace the stream and encode it asprogressive stream. If you deinterlace it with yuvdenoise -F, you willlose details.But if you plan to play the recorded stream on your DVD player and yourTV it would not be wise to perform deinterlacing. If you only want to play itback on the Monitor (progressive display) the picture looks betterwhen playing it back if it is deinterlaced. If the player you use cando deinterlacing it does not matter if your encoded video hasinterlaced frames or progressive frames..PPIf you plan to deinterlace the stream you can only do this withyuvdenoise -F, and set the mpeg2enc -I 0. If you do not want todeinterlace the stream you do not need to set any special option (donot use yuvdenoise -F and mpeg2enc -I 0).PPIf you like to pause the stream and look on the still you shoulddeinterlace. Because then the image is flicker free when pausing..PPIf you have a film (progressive) with parts from a broadcast(interlaced) mixed together (like in a documentary where some partsfrom a speaker are recorded interlaced and other parts are filmed)you have to choose between good film sequences with average still imagesor average looking film sequences with good still images..PPFor good film with average stills do not deinterlace. For average film sequences with good stills then deinterlace (using -F and -I 0)..PPMPEG2 Multiplexing Example.PP\fB> mplex -f 3 -b 300 -r 4750 -V audio.mp3 video.mp3 -o final.mpg\fP.PPNow both streams (a mp3 audio and a mpeg2 video) are multiplex into a single stream (final.mpg). You have to use the -f 3 option to tell mplex the output format. You alsohave to add the -b decoder buffers size with the same value used when encoding the video. -r is that rate of video + audio +1-2% of mplexinformation..PPThe -V option tells that your source for mplexing is a VBR stream. Ifyou don't use this option mplex creates something like a CBR Streamwith the bitrate you have told it with the -r option. These streams areusually get BIG..PP.PP.SH Creating Video-CD's.PPVCD is a constrained version of MEPG1 streams.VCD format was defined by Philips. The goal was to use a single speedCD-drive and other cheap hardware (not flexible) to have acheap HW-Player. Because of that there are some limitations on VCD's.The bitrate for video is 1152kBit and for audio layer 2 audio 224kBit stereo.You are not allowed to use the -q option, dynamic GOP sizes and the video buffer is limited to 46kB.The image size is limited to 352x240 for NTSC, an to 352x288 for PAL..PPIf you have no VCD (only) player and you plan to use your DVD player then it is quite possible that the DVD player will be flexible enough to allow higher bitrates, dynamic GOP sizes, larger video buffer and so on.PPVCD Audio creation Example.PP\fB> lav2wav stream.avi \(br mp2enc -V -o sound.mp2\fP.PP\fB-V\fP force VCD 2.0 compatible output.There the audio samplerate is fixed to 44.1kHz. And you can choose the audiobitrate for mono audio to be 64, 96 or 192kBit/sec. If you have stereo audio you can choose 128, 192, 224 or 384kBit/sec. For hardware players, you should stick to 44.1 224kBps Stereo layer 2 Audio..PPVCD Video creation Example.PP\fB> lav2yuv stream.avi \(br yuvscaler -O VCD \(brmpeg2enc -f 1 -r 16 -o video.mpg\fP.PPFor a VCD compatible output the -f 1 sets all options in mpeg2enc asneeded. It seems that many VCD players (Avex for example) are not able toplay MPEG streams that are encoded with a search radius greater than 16 sodo not use the -r option to override the default of 16..PP\fB> lav2yuv streams.eli \(brmpeg2enc -f 1 -4 1 -2 1 -S 630 -B 260 -P -o video.m1v\fP.PPUsing \fB'-S 630'\fP means that mpeg2enc marks the stream sothat mplex generates a new stream every 630MB. One important thing is the useof the \fB-B\fP option which specifies the non-video (audio and mplexinformation) bitrate. The -B value of 260 should be fine for audiowith 224kBit and mplex information. For further information take a look at the encoding scripts in the scripts directory. So themultiplexed streams should easily fit on a CD with 650MB..PPThe default value (-B) is 700MB for the video. mpeg2enc marksautomatically every stream at that size if the -B option is not used to seta different value. If you have a CD where you can write more data (perhapsas much as 800MB), you have to set the -S option or otherwise mpeg2enc will mark the stream at 700 MB, and mplex will split the stream there. Which is almost certainly not what you want..PP.PP.PPVCD Multiplexing Example.PP\fB> mplex -f 1 sound.mp2 video.mpg -o vcd_out.mpg\fP.PPThe -f 1 option turns on a lot of weird stuff that otherwise has noplace in a respectable multiplexer!.PPCreating the CD.PPThe multiplexed streams have to be converted to an VCD compatible. This is done by vcdimager.PP.PP\fB> vcdimager testvideo.mpg\fP.PPCreates a \fBvideocd.bin\fP, the data file, and a \fBvideocd.cue\fPwhich is used as control file for cdrdao..PPYou use cdrdao to burn the image. Cdrdao is yet another fineSourceforge project which is found at:.PPNotes.PPFor MPEG-1 encoding a typical (45 minute running time) show or 90 oddminute movie from an analog broadcast a constant bit-rate of around1800 kBit/sec should be ideal. The resulting files are around 700M for45 minutes which fits nicely as a raw XA MODE2 data track on a CD-R.For pure digital sources (DTV or DVD streams and similar) VCD 1152works fine..PP\fBNote:\fP If you encode VBR MPEG1 (-q) remember the Hardware wasprobably not designed to do the playback because it is not in thespecifications. If it works be very happy. I've noticed that it helpswhen you have an MPEG1 Stream to tell vcdimager that it is an SVCD.vcdimager complains (but only with a warning and not a fatal error) butyou should be able to burn it. This could convince the player to usedifferent routines in its firmware and play it back correct, but there is no guarantee of that..PPStoring MPEGs.PPIf you record the data as XA mode 2 tracks you can fit appreciablymore on a CD (at the expense of error correction/detection). You canuse vcdimager to do this and vcdxrip (part of the vcdimager package)to extract (\(rqrip\(rq) the resulting files. For better Qualitythere are SVCD and XVCD and DVD..PPCurrently SVCD is fully supported with a pre-set format in mplexand tools to create disks. MPEG streams that can be played by DVDplayer hardware and software can readily produced using mpeg2enc/mplex.PPIf your player doesn't support SVCD you may well find it can handleVCD streams that have much higher than standard bit-rates. Often asmuch as 2500kBit/sec is possible. The several brands of DVD playerscan also play wilding out of spec SVCD and VCD discs.With higher bit-rates and good quality source material it is worthtrying mpeg2enc's -h flag which produce a stream that is as sharp asthe limits of the VCD standard permits. .PPHowever, if your player supports it and you have the patience for thelonger encoding times SVCD is a much better alternative. Using amore efficient MPEG format SVCD more than doubles VCD's resolutionwhile typically producing files that are less than twice as big..SH Creating SVCD.PPSuper Video CD (SVCD) is an enhan
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?