📄 mjpeg_howto.txt
字号:
MJPEG HOWTO - An introduction to the MJPEG-tools Praschinger Bernhard v1.48 MJPEG capture/editting/replay and MPEG encoding toolset description ______________________________________________________________________ Table of Contents 1. Introduction 2. Unsorted list of useful Hints 2.1 Some books we found usefull 3. Recording videos 3.1 lavrec examples 3.2 Other recording hints 3.3 Some information about the typical lavrec output while recording 3.4 Notes about "interlace field order - what can go wrong and how to fix it" 3.4.1 There are three bad things that can happen with fields 3.4.2 How can I recognize if I have one of these Problems ? 3.4.3 How can you fix it? 3.4.4 Hey, what about NTSC movies ? 4. Creating videos from other sources 4.1 Creating videos from images 4.2 Decoding streams with mplayer 4.3 Decoding MPEG2 streams with mpeg2dec 4.4 Other things to know 5. Checking if recording was successful 6. Edit the video 6.1 Edit with glav 6.2 Unify videos 6.3 Separate sound 6.4 Separate images 6.5 Creating movie transitions 7. Converting the stream to MPEG or DIVx videos 7.1 Creating sound 7.2 Converting video 7.2.1 Scaling 7.3 Putting the streams together 7.4 Creating MPEG1 Videos 7.4.1 MPEG1 Audio creation Example 7.4.2 MPEG1 Video creation Example 7.4.3 MPEG1 Multiplexing Example 7.5 Creating MPEG2 Videos 7.5.1 MPEG2 Audio creation Example 7.5.2 MPEG2 Video creation Example 7.5.2.1 Which values should be used for VBR Encoding 7.5.2.2 Encoding destination TV (interlaced) or Monitor (progressive) 7.5.3 MPEG2 Multiplexing Example 7.6 Creating Video-CD's 7.6.1 VCD Audio creation Example 7.6.2 VCD Video creation Example 7.6.3 VCD Multiplexing Example 7.6.4 Creating the CD 7.6.5 Notes 7.6.6 Storing MPEGs 7.7 Creating SVCD 7.7.1 SVCD Audio creation Example 7.7.2 SVCD Video creation Example 7.7.3 SVCD Multiplexing Example 7.7.4 SVCD Creating the CD 7.8 Creating DVD's 7.8.1 DVD Audio creation Example 7.8.2 DVD Video creation Example 7.8.3 DVD Mplex Example 7.8.4 DVD creation Example 7.9 Creating DIVX Videos 7.9.1 lav2avi.sh 8. Optimizing the stream 8.1 Scaling and offset correction 8.2 Frame rate conversion 9. Transcoding of existing MPEG-2 9.1 If you want to do every step on your own it will look something like this 10. Trading Quality/Speed 10.1 Creating streams to be played from disk using Software players 11. SMP and distributed Encoding 12. Interoperability ______________________________________________________________________ 1. Introduction I wrote this things down, because I had many sheets with notes on them. This should be some kind of summary of collected knowledge of this sheets. Andrew Stevens helped with encoding and VCD knowledge and hints. The mjpegtools are a set of programs that can do recording, playback, editing and eventual MPEG compression of audio and video under Linux. Although primarily intended for use with capture / playback boards based on the Zoran ZR36067 MJPEG codec chip, the mjpegtools can easily be used to process and compress MJPEG video streams captured using xawtv using simple frame-buffer devices. The HOWTO for the tools intended to give an an introduction to the MJPEG-tools and the creation of MPEG 1/2 videos. VCD and SVCD, and the transcoding of existing mpeg streams. For more information about the programs read the corresponding man- page. Achtung es gibt auch eine deutsche Version bei: http://sourceforge.net/projects/mjpeg There is also a manpage of this text, you can read it with "man mjpegtools" if installed. The text version of this text is available via cvs, you should get it with a tarball or the precompiled package (RPM and deb). In the following picture you see the typical workflow when you record a video. Cut it afterwards and encode it. In the picture you also see the connections to other programs. These parts are in grey, the parts in blue can be done with the mjpegtools. Video encoding workflow 2. Unsorted list of useful Hints You have to compile and install the mjpeg_play package, for this read the README & REQUIRED_SOFTWARE & INSTALL. If you do not want to compile it, you can download the mjpeg .RPM or .DEB package at Sourceforge. There is a script in the scripts/ directory. This script is something that show's you a way how it can be done. It also creates (under certain circumstances) videos that look quite good. Better videos you only get by tuning the parameters yourself. You will usually have to load the drivers for the Buz or DC10 or LML33 cards.So you have to run the update script providing as option the name of your card you have. The script is usually in /usr/src/driver- zoran/. The zoran kernel driver below the kernel 2.4.4 do not work. You have to use the driver available from: http://mjpeg.sourceforge.net/driver-zoran The driver for the Matrox Marvel card also works, more information about it: http://marvel.sourceforge.net If you compile the tools on a P6 based computer (PPro, P-II, P-III, P-4, Athlon,Duron) then never try to let them run on a P5 based computer (Pentium, Pentium-MMX, K6, K6-x, Cyrix, Via, Winchip). You'll get a "illegal instruction" and the program won't work. If lav2yuv dumps core then one possible cause is no dv support was included. To enable it make sure that libdv is installed on the system. This will be necessary if you are using a digital camera (or analog to DV converter such as the Canopus ADVC100) and converting the dv avi format into the MPEG format. Start xawtv to see if you get an picture. If you want to use HW- playback of the recorded streams you have to start xawtv (any TV application works) once to get the streams played back. You should also check the settings of your mixer in the sound card. If you compile the tools on a platform other than Linux not all tools will work. Mjpegtools on a OS/X system for example will not have V4L (video4linux) capability. Never try to stop or start the TV application when lavrec runs. If you start or stop the TV application lavrec will stop recording, or your computer could get "frozen". This is a problem of v4l (video4linux). This problem is solved with v4l2. If you use v4l2 you can record the video and stop and start the tv application whenever you want. But v4l2 is currently (7. Jan. 2003) only supported for the zoran based cards (BUZ, DC10, DC10+, LML33) if you use the CVS driver from mjpeg.sf.net tagged with ZORAN_VIDEODEV_2. And this driver only works with the 2.4.20 kernel and the 2.5.* development kernel. One last thing about the data you get before we start: Audio: ( Samplerate * Channels * Bitsize ) / (8 * 1024) CD Quality:(44100 Samples/sec * 2 Chanels * 16 Bit) / (8 * 1024)=172,2 kB/sec The 8 * 1024 convert the value from bit/sec to kByte/sec Video: (width * height * framerate * quality ) / (200 * 1024) PAL HALF Size : (352 * 288 * 25 * 80) / (200 * 1024) = 990 kB/sec PAL FULL size : (720 * 576 * 25 * 80) / (200 * 1024) = 4050 kB/sec NTSC HALF size: (352 * 240 * 30 * 80) / (200 * 1024) = 990 kB/sec NTSC FULL size: (720 * 480 * 30 * 80) / (200 * 1024) = 4050 kB/sec The 1024 converts the Bytes to kBytes. Not every card can record the size mentioned. The Buz and Marvel G400 for example can only record a size of 720x576 when using -d 1, the DC10 records a size of 384x288 when using -d 2. When you add audio and video datarate this is what your hard disk has to be able to write constantly streaming, else you will have lost frames. If you want to play with the --mjpeg-buffer-size. Remember the value should be at least big enough that one frame fits in it. The size of one frame is: (width * height * quality ) / (200 * 1024) = kB If the buffer is too small the rate calculation doesn't match any more and buffer overflows can happen. The maximum value is 512kB. How video works and the difference between the video types is explained here: http://www.mir.com/DMG/ There you also find how to create MPEG Still Images for VCD/SVCD. A good description of DV (Digital Video) can be found here: http://www.iki.fi/znark/video/conversion/ 2.1. Some books we found usefull written in English: o Digital Video and HDTV by Charles Poyton (ISBN 1-55860-792-7) o Digital Video Compression by Peter Symes (ISBN 0-07-142487-3) o Video Demystified by Keith Jack (ISBN 1-878707-56-6) written in German: o Fernsehtechnik von Rudolf Maeusl (ISBN 3-7785-2374-0) o Professionelle Videotechnik - analoge und digitale Grundlagen von U. Schmidt (ISBN 3-540-43974-9) o Digitale Film- und Videotechnik von U. Schmidt (ISBN 3-446-21827-0) If you know some other really good book about that, write us! 3. Recording videos 3.1. lavrec examples Recording with lavrec look's like this: > lavrec -f a -i P -d 2 record.avi Should start recording now, -f a use AVI as output format, -i P use as input source the SVHS-In with PAL format, -d 2 the size of the pictures are half size (352x288) record.avi name of the created file. Recording is finished by pressing Crtl-C (nowadays: Strg-C). Sometimes using -f A instead of -f a might be necessary Other example: > lavrec -f q -i n -d 1 -q 80 -s -l 80 -R l -U record.avi Should start recording now, -f q use Quicktime as output format, -i n use Composite-In with NTSC format, -d 1 record pictures with full size (640x480) -q 80 set the quality to 80% of the captured image -s use stereo mode (default mono) -l 80 set the recording level to 80% of the max during recording -R l set the recording source to Line-In -U With this lavrec uses the read instead of mmap for recording this is needed if your sound card does not support the mmap for recording. Setting the mixer does not work with every sound card. If you record with 2 different settings and both recordings are equally loud you should setup the mixer with a mixer program. After that you should use the -l -1 option when you record using lavrec The size of the image depends on the card you use. At full size (-d 1) you get these image sizes: BUZ and LML33: 720x576, the DC10: 768x576 Other example: > lavrec -w -f a -i S -d 2 -l -1 record%02d.avi Should start recording, -w Waits for user confirmation to start (press enter) -f a use AVI as output format, -i S use SECAM SVHS-Input (SECAM Composite recording is also possible: -i s) -d 2 the size of the pictures are half size -l -1 do not touch the mixer settings record%02d.avi Here lavrec creates the first file named record00.avi after the file has reached a size of 1.6GB (after about 20 Minutes recording) it starts a new sequence named record01.avi and so on till the recording is stopped or the disk is full
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -