mjpegtools.1
来自「Motion JPEG编解码器源代码」· 1 代码 · 共 2,296 行 · 第 1/5 页
1
2,296 行
.PPYou can decode mpeg2 streams with the patched mpeg2dec version which creates yuv streams. You can pipe that into any other mjpegtools program. Or you use a mpeg2dec version directly from the libmpeg2 project and use the output mode pgmpipe. With the \fBpgmtoy4m\fP program from the mjpegtools you can convert that pgm output back to yuv..PP.PPIf you ask yourself why there is a patched version and pgmtoy4m.The answer is that the patch for yuv output was sent severaltimes to the libmpeg2 developers but was never included.Now we have two ways around that problem. Decoding looks like this:.PP\fB> mpeg2dec -s -o pgmpipe ANYTS.VOB \(br pgmtoy4m -i t -a 10:11 -r 30000:1001 \(br mpeg2enc -f 8 newvideo.m2v\fP.PPYou can decode the audio as described in the \fBTranscoding of existing MPEG-2\fP Section..PP.SH Other things to know.PPIf you have Transport Streams from your DVB card, or os Satelite Receiveryou might want to demultiplex or cut them. A nice tool for that is \fBProject X\fP available from: .PPYou can process the streams afterwards as you would do with any mpeg movieor demultiplexed audio video. So the \fBTranscoding of existing MPEG-2\fPsection of this document will be of interest.Checking if recording was successful.PPYou can use lavplay or glav. \fBIMPORTANT: NEVER\fP try to run xawtvand lavplay or glav with hardware playback, it will not work. Forsoftware playback it works fine..PP\fB>lavplay -p S record.avi\fP.PPYou should see the recorded video and hear the sound. But the decodingof the video is done by the CPU which will place a heavy load on the system.The advantage of this method is you don't need xawtv..PPThe better way:.PP\fB>lavplay -p H record.avi\fP.PPThe video is decoded and played by the hardware. The system load isnow very low. This will play it back on-screen using the hardware rather thansoftware decoding..PPYou might also try:.PP\fB> lavply -p C record.avi\fP.PPWhich will play it back using the hardware but to the video output ofthe card..PP\fB> glav record.avi\fP.PPDoes the same as lavplay but you have an nice GUI. The options forglav and lavplay are nearly the same. Using no option SW playback is used..PPUsing hardware playback a signal for the Composite and SVHS OUT isgenerated so you can view the movie on your TV..PP\fB> lav2yuv test.eli \(br yuvplay\fP.PPIs a other way to get the video without sound. You can use yuvplayonce in the encoding command. When you use yuvplay in the encodingcommand you see the changes made by filters and scaling. You can alsouse it for slow-motion debugging..PP\fBNOTE:\fP After loading the driver's you have to start xawtv toset up some things lavplay and glav do not, but they are needed forHW-Playback. Don't forget to close xawtv !!.PP.PP\fBNOTE2:\fP Do not try to send glav an lavplay into background, wont workcorrect !!!.PP\fBNOTE3:\fP SECAM playback is now (12.3.2001) only in monochrome, but therecording and encoding is done right..PP\fBNOTE4:\fPBad cables may reduce the quality of the image. Normallyyou can't see this but when there is text you might notice a smallshadow. When you see this you should change the cable..PP\fBComing soon:\fP There is a tool which makes recoding videos very simple:Linux Studio. You can download it at:.PPEdit the video.PP.SH Edit with glav.PPMost tasks can be easily done by glav. Like deleting parts of the video,cut paste and copy parts of the videos..PPglav button description.PP.PP.PPThe modifications should be saved because glav does not destructively editthe video. This means that the original video is left untouchedand the modifications are kept in an extra \(rqEdit List\(rq filereadable with a text editor. These files can be used as an input to the otherlavtools programs such as lav2wav, lav2yuv, lavtrans..PPIf you want to cut off the beginning and the end of the stream mark thebeginning and the and, and use the \(rqsave select\(rq button. Theedit list file is than used as input for the lavtools. If you want to splita recorded video to some smaller parts simply select the parts and then save each part to a different listfile..PPYou can see all changes to the video and sound NOW and you do not need torecalculate anything..PPIf you want to get a \&"destructive\&" version of your edited video use:.PP\fB> lavtrans -o short_version.avi -f a editlist.eli\fP.PP.nr ll +1.nr t\n(ll 2.if \n(ll>1 .RS.IP "-o".nr bi 1.PPspecifies the output name.IP "-f a".nr bi 1.PPspecifies the output format (AVI for example).IP "editlist.eli".nr bi 1.PPis the list file where the modifications are described.You generate the list file with the \&"save all\&" or \(rqsave select\(rqbuttons in glav..if \n(ll>1 .RE.nr ll -1.PP.SH Unify videos.PP\fB> lavtrans -o stream.qt -f q record_1.avi record_2.avi ... record_n.avi\fP.PP.nr ll +1.nr t\n(ll 2.if \n(ll>1 .RS.IP "-o".nr bi 1.PPspecifies the outputfile name.IP "-f q".nr bi 1.PPspecifies the output format, quicktime in this case.if \n(ll>1 .RE.nr ll -1.PPThis is usually not needed. Keep in your mind that there is the 2GBfile-size-limit on 32Bit systems with an older glibc..PP.SH Separate sound.PP\fB> lavtrans -o sound.wav -f w stream.avi\fP.PPCreates a wav file with the sound of the stream.aviMaybe needed if you want to remove noise or if you wantto convert it to another sound format..PPAnother way to split the sound is:.PP\fB> lav2wav editlist.eli >sound.wav\fP.PP.SH Separate images.PP\fB>mkdir jpg; lavtrans -o jpg/image%05d.jpg -f i stream.avi\fP.PPFirst create the directory \(rqjpg\(rq\&. Then lavtrans will createsingle JPG images in the jpg directory from the stream.avi file. Thefiles will be named: image00000.jpg, image00001.jpg .....PPThe jpg images created contain the whole picture. But if you have recorded at full size the images are stored interlaced. Usually the picture viewersshow only the first field in the jpg file..PP.PP.PPIf you want to have the image in a single file you can use that version.PP\fB> lav2yuv -f 1 stream.avi \(br y4mtoppm -L >file.pnm\fP.PPIf you want to split the fields into single files use that:.PP\fB> lav2yuv -f 5 ../stream.avi \(br y4mtoppm \(brpnmsplit - image%d.pnm\fP.PPMaybe interesting if you need sample images and do not want to playaround with grabbing a single image..PP.SH Creating movie transitions.PPThanks to Philipp Zabel's lavpipe, we can now make simple transitionsbetween movies or combine multiple layers of movies..PPPhilipp wrote this HOWTO on how to make transitions:.PPLet's assume simple this scene: We have two input videos intro.aviand epilogue.mov and want to make intro.avi transition into epilogue.mov with aduration of one second (that is 25 frames for PAL or 30 frames for NTSC)..PPIntro.avi and epiloque.mov have to be of the same format (the sameframe rate and resolution). In this example theyare both 352x288 PAL files. intro.avi contains 250 frames andepilogue.mov is 1000 frames long..PPTherefore our output file will contain: .PP.nr ll +1.nr t\n(ll 2.if \n(ll>1 .RS.IP "".nr bi 1.PPthe first 225 frames of intro.avi.IP "".nr bi 1.PPa 25 frame transition containing the last 25 frames of intro.avi andthe first 25 frames of epilogue.mov.IP "".nr bi 1.PPthe last 975 frames of epilogue.mov.if \n(ll>1 .RE.nr ll -1.PPWe could get the last 25 frames of intro.avi by calling:.PP\fB>lav2yuv -o 225 -f 25 intro.avi\fP.PP\fB-o 255\fP, the offset, tells lav2yuv to begin with frame # 225 and\fB -f 25\fP makes it output 25 frames from there on..PPAnother possibility is:.PP\fB> lav2yuv -o -25 intro.avi\fP.PPSince negative offsets are counted from the end..PPAnd the first 25 frames of epilogue.mov:.PP\fB> lav2yuv -f 25 epilogue.mov\fP.PP\fB-o\fP defaults to an offset of zero.PP.PPBut we need to combine the two streams with lavpipe. So the call would be:.PP\fB> lavpipe \(rqlav2yuv -o 255 -f 25 intro.avi\(rq \(rqlav2yuv -f 25 epilogue.mov\(rq \fP.PPThe output of this is a raw yuv stream that can be fed into transist.flt..PPtransist.flt needs to be informed about the duration of the transition andthe opacity of the second stream at the beginning and at the end of thetransition:.PP.nr ll +1.nr t\n(ll 2.if \n(ll>1 .RS.IP "-o num".nr bi 1.PPopacity of second input at the beginning [0-255].IP "-O num".nr bi 1.PPopacity of second input at the end [0-255].IP "-d num".nr bi 1.PPduration of transition in frames.if \n(ll>1 .RE.nr ll -1.PPAn opacity of 0 means that the second stream is fully transparent(only stream one visible), at 255 stream two is fully opaque..PPIn our case the correct call (transition from stream 1 to stream 2)would be:.PP\fB> transist.flt -o 0 -O 255 -d 25\fP.PPThe -s and -n parameters equate to the -o and -f parameters of lav2yuvand are only needed if anybody wants to render only a portion of the transition for whatever reason. Please note that this only affects theweighting calculations - none of the input is really skipped. If youuse the skip parameter (-s 30, for example) you also need to skip the first30 frames in lav2yuv (-o 30) in order to get the expected result. If youdidn't understand this send an email to the authors or simply ignore-s and -n. The whole procedure will eventually be automated..PP.PPNow we want to compress the yuv stream with yuv2lav:.PP\fB> yuv2lav -f a -q 80 -o transition.avi\fP.PPReads the yuv stream from stdin and outputs an avi file (-f a) withcompressed jpeg frames of quality 80..PPNow we have the whole command for creating a transition:.PP\fB> ypipe \(rqlav2yuv -o 255 -f 25 intro.avi\(rq \(rqlav2yuv-f 25 epilogue.mov\(rq \(br transist.flt -o 0 -O 255 -d 25 \(br yuv2lav -f a -q 80 -o transition.avi\fP.PPThe resulting video can be written as a LAV Edit List, a plain text filecontaining the following lines:.PP.DS.sp .ft RR.nfLAV Edit ListPAL3intro.avitransition.aviepilogue.mov0 0 2241 0 242 25 999.DE.fi .ec.ft P.sp.PPThis file can be fed into glav or lavplay, or you can pipe it into mpeg2enc with lav2yuv or combine the whole stuff into one single mjpegfile with lavtrans or lav2yuv\(bryuv2lav..PPConverting the stream to MPEG or DIVx videos.PP
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?