📄 mjpeg_howto.txt
字号:
try: >convert *.gif ppm:- | ppmtoy4m | yuvplay That means take all '.jpg' images in directory, convert to PPM format, and pipe to stdout, then ppmtoy4m processes them .... 4.2. Decoding streams with mplayer Decoding the streams with mplayer is a nice way of bringing every video that mplayer can play back to something you can edit or encode directly to a mpeg video with the mjpegtools. This method works with mplayer 1.0pre2 or newer >mkfifo stream.yuv >mplayer -nosound -noframedrop -vo yuv4mpeg anyfile.mpg & >cat stream.yuv | yuv2lav -o mjpeg_wo.avi >mplayer -vo null -ao pcm -aofile anyfile.wav anyfile.mpg Now you have for example a mjpeg encoded AVI without sound. The sound will be in anyfile.wav. Now you can choose if you want to add the sound to the AVI with lavaddwav and edit the file and encode it. You can also use instead of yuv2lav, mpeg2enc or any other tool from the mjpeg tools so your command might also look like that: > cat stream.yuv | yuvdenoise | yuvscaler -O SVCD | mpeg2enc -f 4 -o video_svcd.m2v And cat the wav file into mp2enc to encode it to MP2 audio. The -vo yuv4mpeg option works well with other input types mentioned in the mplayer documentation. 4.3. Decoding MPEG2 streams with mpeg2dec You 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 pgmtoy4m program from the mjpegtools you can convert that pgm output back to yuv. If you ask yourself why there is a patched version and pgmtoy4m. The answer is that the patch for yuv output was sent several times to the libmpeg2 developers but was never included. Now we have two ways around that problem. Decoding looks like this: > mpeg2dec -s -o pgmpipe ANYTS.VOB | pgmtoy4m -i t -a 10:11 -r 30000:1001 | mpeg2enc -f 8 newvideo.m2v You can decode the audio as described in the Transcoding of existing MPEG-2 Section. 4.4. Other things to know If you have Transport Streams from your DVB card, or os Satelite Receiver you might want to demultiplex or cut them. A nice tool for that is Project X available from: http://forum.lucike.info/ You can process the streams afterwards as you would do with any mpeg movie or demultiplexed audio video. So the Transcoding of existing MPEG-2 section of this document will be of interest. 5. Checking if recording was successful You can use lavplay or glav. IMPORTANT: NEVER try to run xawtv and lavplay or glav with hardware playback, it will not work. For software playback it works fine. >lavplay -p S record.avi You should see the recorded video and hear the sound. But the decoding of 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. The better way: >lavplay -p H record.avi The video is decoded and played by the hardware. The system load is now very low. This will play it back on-screen using the hardware rather than software decoding. You might also try: > lavply -p C record.avi Which will play it back using the hardware but to the video output of the card. > glav record.avi Does the same as lavplay but you have an nice GUI. The options for glav and lavplay are nearly the same. Using no option SW playback is used. Using hardware playback a signal for the Composite and SVHS OUT is generated so you can view the movie on your TV. > lav2yuv test.eli | yuvplay Is a other way to get the video without sound. You can use yuvplay once in the encoding command. When you use yuvplay in the encoding command you see the changes made by filters and scaling. You can also use it for slow-motion debugging. NOTE: After loading the driver's you have to start xawtv to set up some things lavplay and glav do not, but they are needed for HW- Playback. Don't forget to close xawtv !! NOTE2: Do not try to send glav an lavplay into background, wont work correct !!! NOTE3: SECAM playback is now (12.3.2001) only in monochrome, but the recording and encoding is done right. NOTE4:Bad cables may reduce the quality of the image. Normally you can't see this but when there is text you might notice a small shadow. When you see this you should change the cable. Coming soon: There is a tool which makes recoding videos very simple: Linux Studio. You can download it at: http://ronald.bitfreak.net 6. Edit the video 6.1. Edit with glav Most tasks can be easily done by glav. Like deleting parts of the video, cut paste and copy parts of the videos. glav button description The modifications should be saved because glav does not destructively edit the video. This means that the original video is left untouched and the modifications are kept in an extra "Edit List" file readable with a text editor. These files can be used as an input to the other lavtools programs such as lav2wav, lav2yuv, lavtrans. If you want to cut off the beginning and the end of the stream mark the beginning and the and, and use the "save select" button. The edit list file is than used as input for the lavtools. If you want to split a recorded video to some smaller parts simply select the parts and then save each part to a different listfile. You can see all changes to the video and sound NOW and you do not need to recalculate anything. If you want to get a "destructive" version of your edited video use: > lavtrans -o short_version.avi -f a editlist.eli -o specifies the output name -f a specifies the output format (AVI for example) editlist.eli is the list file where the modifications are described. You generate the list file with the "save all" or "save select" buttons in glav. 6.2. Unify videos > lavtrans -o stream.qt -f q record_1.avi record_2.avi ... record_n.avi -o specifies the outputfile name -f q specifies the output format, quicktime in this case This is usually not needed. Keep in your mind that there is the 2GB file-size-limit on 32Bit systems with an older glibc. 6.3. Separate sound > lavtrans -o sound.wav -f w stream.avi Creates a wav file with the sound of the stream.avi Maybe needed if you want to remove noise or if you want to convert it to another sound format. Another way to split the sound is: > lav2wav editlist.eli >sound.wav 6.4. Separate images >mkdir jpg; lavtrans -o jpg/image%05d.jpg -f i stream.avi First create the directory "jpg". Then lavtrans will create single JPG images in the jpg directory from the stream.avi file. The files will be named: image00000.jpg, image00001.jpg .... The jpg images created contain the whole picture. But if you have recorded at full size the images are stored interlaced. Usually the picture viewers show only the first field in the jpg file. If you want to have the image in a single file you can use that version > lav2yuv -f 1 stream.avi | y4mtoppm -L >file.pnm If you want to split the fields into single files use that: > lav2yuv -f 5 ../stream.avi | y4mtoppm | pnmsplit - image%d.pnm Maybe interesting if you need sample images and do not want to play around with grabbing a single image. 6.5. Creating movie transitions Thanks to Philipp Zabel's lavpipe, we can now make simple transitions between movies or combine multiple layers of movies. Philipp wrote this HOWTO on how to make transitions: Let's assume simple this scene: We have two input videos intro.avi and epilogue.mov and want to make intro.avi transition into epilogue.mov with a duration of one second (that is 25 frames for PAL or 30 frames for NTSC). Intro.avi and epiloque.mov have to be of the same format (the same frame rate and resolution). In this example they are both 352x288 PAL files. intro.avi contains 250 frames and epilogue.mov is 1000 frames long. Therefore our output file will contain: the first 225 frames of intro.avi a 25 frame transition containing the last 25 frames of intro.avi and the first 25 frames of epilogue.mov the last 975 frames of epilogue.mov We could get the last 25 frames of intro.avi by calling: >lav2yuv -o 225 -f 25 intro.avi -o 255, the offset, tells lav2yuv to begin with frame # 225 and -f 25 makes it output 25 frames from there on. Another possibility is: > lav2yuv -o -25 intro.avi Since negative offsets are counted from the end. And the first 25 frames of epilogue.mov: > lav2yuv -f 25 epilogue.mov -o defaults to an offset of zero But we need to combine the two streams with lavpipe. So the call would be: > lavpipe "lav2yuv -o 255 -f 25 intro.avi" "lav2yuv -f 25 epilogue.mov" The output of this is a raw yuv stream that can be fed into transist.flt. transist.flt needs to be informed about the duration of the transition and the opacity of the second stream at the beginning and at the end of the transition: -o num opacity of second input at the beginning [0-255] -O num opacity of second input at the end [0-255] -d num duration of transition in frames An opacity of 0 means that the second stream is fully transparent (only stream one visible), at 255 stream two is fully opaque. In our case the correct call (transition from stream 1 to stream 2) would be: > transist.flt -o 0 -O 255 -d 25 The -s and -n parameters equate to the -o and -f parameters of lav2yuv and are only needed if anybody wants to render only a portion of the transition for whatever reason. Please note that this only affects the weighting calculations - none of the input is really skipped. If you use the skip parameter (-s 30, for example) you also need to skip the first 30 frames in lav2yuv (-o 30) in order to get the expected result. If you didn't understand this send an email to the authors or simply ignore -s and -n. The whole procedure will eventually be automated. Now we want to compress the yuv stream with yuv2lav: > yuv2lav -f a -q 80 -o transition.avi Reads the yuv stream from stdin and outputs an avi file (-f a) with compressed jpeg frames of quality 80. Now we have the whole command for creating a transition: > ypipe "lav2yuv -o 255 -f 25 intro.avi" "lav2yuv -f 25 epilogue.mov" | transist.flt -o 0 -O 255 -d 25 | yuv2lav -f a -q 80 -o transition.avi The resulting video can be written as a LAV Edit List, a plain text file containing the following lines: LAV Edit List PAL 3 intro.avi transition.avi epilogue.mov 0 0 224 1 0 24
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -