⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mjpeg_howto.txt

📁 Motion JPEG编解码器源代码
💻 TXT
📖 第 1 页 / 共 5 页
字号:
     -b 1500        a Bitrate of 1500kBit/sec     -n s        the input Video norm is forced to SECAM     -P This ensures that 2 B frames appear between adjacent I/P frames.        Several common MPEG-1 decoders can't handle streams that do not        have 2 B-frames between I/P frames     -g 6 -G 20        the encoder can dynamically change the group-of-pictures size to        reflect scene changes. This is done by setting a maximum 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.  Example  > lav2yuv stream*.avi | mpeg2enc -b 1500 -r 16 -4 1 -2 1 -S 630 -B 260  -o video_n1_1500_r16_41_21_S630_B240.m1v  lav2yuv processes all the stream files. Then mpeg2enc is given some  options that make the encoded stream look nicer. Using -S 630 means  that mpeg2enc marks the stream so that mplex generates a new stream  every 630MB. One important thing is the use of the -B option which  specifies the non-video (audio and mplex information) bitrate. The -B  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.  7.4.3.  MPEG1 Multiplexing Example  Example   >mplex sound.mp2 video.m1v -o my_video.mpg  Puts 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  with mpeg2enc).  Example  mplex -V -r 1740 audio.mp2 video_vbr.m1v -o vbr_stream.mpg  Here we multiplex a variable bitrate stream. mplex is now a single  pass multiplexer so it can't detect the maximal bitrate and we have to  specify it. The data rate for the output stream is: audio bitrate +  peak videobitrate + 1-2% for mplex information. 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.  7.5.  Creating MPEG2 Videos  MPEG2 is recommended for sources with a greater picture than 352x240  for NTSC and 352x288 for PAL. MPEG2 can also handle interlaced sources  like recording from TV at full resolution.  MPEG2 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.  MPEG2 is usually a VBR Stream. MPEG2 creation with optimization  requires a lot of CPU power.  A film with the double resolution is NOT  4 times larger than an MPEG1 Stream. Depending on your quality  settings it will be about 1.5 up to 3 times larger than the MPEG1  Stream at its lower resolution.  7.5.1.  MPEG2 Audio creation Example  > lav2wav editlist.eli | mp2enc -o sound.mp2  This will fit the MPEG2 quite well. You can save some bits by telling  mp2enc to use a lower bitrate (-b option) like 160 or 192 kBit/s. And  might want to add -r 44100 so that mpeg2enc generates a 44.1kHz  sampling rate audio file. 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.  7.5.2.  MPEG2 Video creation Example  > lav2yuv editlist.eli | mpeg2enc -f 3 -b 3000 -q 9 -o video.m2v  A very simple example for MPEG2 Video.  The most important option is  the -f 3. That tells mpeg2enc that it should create a MPEG2 stream.  Because it is a generic MPEG2 you have to use the -b bitrate options.  And should use the -q option because you 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 has an upper bound of  the value specified by -b.  > lav2yuv editlist.eli | mpeg2enc -f 3 -4 1 -2 1 -q7 -b 4500 -V 300 -P  -g 6 -G 18 -I 1 -o video.m2v  This 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 size  used for decoding the stream. For SW playback it can be much higher  than the default. Dynamic GOP is set with -g and -G.  A larger GOP  size can help reduce the bit-rate required for a given quality but  very large sizes can introduce artifacts due to DCT/iDCT accumulated  rounding errors.  The -P option also ensures that 2 B frames appear  between adjacent I/P frames. The -I 1 option tells mpeg2enc that the  source is a interlaced material like videos. There is (time consuming)  interlaced motion compensation logic present in mpeg2enc.  Mpeg2enc  will use that logic if the size of the frames you encode is larger  than the VCD size for your TV Norm.  If 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 0  option 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  will not cause problems, the encoding will just take longer.  You can also use scaling an options that optimize (denoise) the images  to get smaller streams.  These options are explained in detail in the  following sections.  7.5.2.1.  Which values should be used for VBR Encoding  The -q option controls the minimum quantization of the output stream.  Quantization controls the precision with which image information is  encoded. The lower the value the better the image quality.  Values  below 4 are extremes and should only be used if you know what you are  doing  Usually 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 option that  produces a nice movie without using too much bandwidth and does not  introduce too many artifacts.  A quality factor should be chosen that way that the mplex output of  Peak bit-rate and average bit-rate differ by about 20-25%.  If the  difference is very small (less than < 10%) it is likely that you will  begin to see artifacts in high motion scenes.  The most common cause  of the average rate being too close (or equal) to the maximum rate is  wrong value for the maximal bitrate or a quality factor that is too  high.  A combination that will produce more artifacts than you can count is a  SVCD with a maximal video bitrate of 2500kBit and a qualitfactor set  to 1 or 2.  For SVCD with a video limit of 2500kBit a quality factor  of 7-11 fits quite 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 can use a quality factor of 6 when creating  SVCDs.  If your SVCD/DVD player supports higher bitrates than the  official 2788kBit/sec for the video and audio.   When using a higher  bitrate and quality factor action scenes will look much better but of  course the playing time of the disc will be less.  The same (7-11) quality factor for a full size picture and a top  bitrate of 3500 to 4000 kBit will produce few artifacts.  For SVCD/DVD you can expect a result like the one described if the  maximal bitrate is not set too low:     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  7.5.2.2.  Encoding destination TV (interlaced) or Monitor (progres-  sive)  MPEG2 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.  If you encode a film both fields should be the same. Deinterlace the  stream with yuvdenoise -F, or if you have a high quality source, and  don't need to use the denoiser, with yuvcorrect -T NOT_INTERLACED.  Also set the mpeg2enc interlace-mode (-I) option to 0. This means that  there 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 a single progressive frame.  This movie should play back an any device (TV or Monitor) without  problems.  If you have an interlaced source (broadcast) you can encode it as  interlaced stream. Or deinterlace the stream and encode it as  progressive stream. If you deinterlace it with yuvdenoise -F, you will  lose details.  But if you plan to play the recorded stream on your DVD  player and your TV it would not be wise to perform deinterlacing.  If  you only want to play it back on the Monitor (progressive display) the  picture looks better when playing it back if it is deinterlaced. If  the player you use can do deinterlacing it does not matter if your  encoded video has interlaced frames or progressive frames.  If you plan to deinterlace the stream you can only do this with  yuvdenoise -F, and set the mpeg2enc -I 0. If you do not want to  deinterlace the stream you do not need to set any special option (do  not use yuvdenoise -F and mpeg2enc -I 0)  If you like to pause the stream and look on the still you should  deinterlace. Because then the image is flicker free when pausing.  If you have a film (progressive) with parts from a broadcast  (interlaced) mixed together (like in a documentary where some parts  from a speaker are recorded interlaced and other parts are filmed) you  have to choose between good film sequences with average still images  or average looking film sequences with good still images.  For good film with average stills do not deinterlace.  For average  film sequences with good stills then deinterlace (using -F and -I 0).  7.5.3.  MPEG2 Multiplexing Example  > mplex -f 3 -b 300 -r 4750 -V audio.mp3 video.mp3 -o final.mpg  Now 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 also have 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 mplex information.  The -V option tells that your source for mplexing is a VBR stream. If  you don't use this option mplex creates something like a CBR Stream  with the bitrate you have told it with the -r option.  These streams  are usually get BIG.  7.6.  Creating Video-CD's  VCD is a constrained version of MEPG1 streams.  VCD format was defined  by Philips. The goal was to use a single speed CD-drive and other  cheap hardware (not flexible) to have a cheap 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.  If 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  7.6.1.  VCD Audio creation Example  > lav2wav stream.avi | mp2enc -V -o sound.mp2  -V force VCD 2.0 compatible output.  There the audio samplerate is  fixed to 44.1kHz. And  you can choose the audio bitrate 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.  7.6.2.  VCD Video creation Example  > lav2yuv stream.avi | yuvscaler -O VCD | mpeg2enc -f 1 -r 16 -o  video.mpg  For a VCD compatible output the -f 1 sets all options in mpeg2enc as  needed. It seems that many VCD players (Avex for example) are not able  to play MPEG streams that are encoded with a search radius greater  than 16 so do not use the -r option to override the default of 16.  > lav2yuv streams.eli | mpeg2enc -f 1 -4 1 -2 1 -S 630 -B 260 -P -o  video.m1v  Using '-S 630' means that mpeg2enc marks the stream so that mplex  generates a new stream every 630MB. One important thing is the use of  the -B option which specifies the non-video (audio and mplex  information) bitrate. The -B 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. So the  multiplexed streams should easily fit on a CD with 650MB.  The default value (-B) is 700MB for the video. mpeg2enc marks  automatically every stream at that size if the -B option is not used  to set a different value.  If you have a CD where you can write more  data (perhaps as 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.  7.6.3.  VCD Multiplexing Example  > mplex -f 1 sound.mp2 video.mpg -o vcd_out.mpg  The -f 1 option turns on a lot of weird stuff that otherwise has no  place in a respectable multiplexer!  7.6.4.  Creating the CD  The multiplexed streams have to be converted to an VCD compatible.  This is done by vcdimager http://www.vcdimager.org/  > vcdimager testvideo.mpg  Creates a videocd.bin, the data file, and a videocd.cue which is used  as control file for cdrdao.  You use cdrdao to burn the image. Cdrdao is yet another fine  Sourceforge project which is found at: http://cdrdao.sourceforge.net/  7.6.5.  Notes  For MPEG-1 encoding a typical (45 minute running time) show or 90 odd  minute movie from an analog broadcast a constant bit-rate of around  1800 kBit/sec should be ideal. The resulting files are around 700M for  45 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 1152  works fine.  Note: If you encode VBR MPEG1 (-q) remember the Hardware was probably  not designed to do the playback because it is not in the  specifications. If it works be very happy. I've noticed that it helps  when 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)  but you should be able to burn it. This could convince the player to  use different routines in its firmware and play it back correct, but  there is no guarantee of that.  7.6.6.  Storing MPEGs  If you record the data as XA mode 2 tracks you can fit appreciably  more on a CD (at the expense of error correction/detection). You can  use vcdimager to do this and vcdxrip (part of the vcdimager package)  to extract ("rip") the resulting files. For better Quality there are  SVCD and XVCD and DVD.  Currently SVCD is fully supported with a pre-set format in mplex and  tools to create disks. MPEG streams that can be played by DVD player  hardware and software can readily produced using mpeg2enc/mplex  If your player do

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -