carta

mjpegtools(1) on Linux

The text b248fbdca237, as Debian 13 (Trixie), Debian 12 (Bookworm), Debian 11 (Bullseye), Debian 10 (Buster), Debian 9 (Stretch), Debian 8 (Jessie) shipped it.

An introduction to the MJPEG-tools 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 over a long period of time. Andrew Stevens helped with encoding and VCD knowledge and hints. Mjpegtools is 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 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, SVCD and DVD 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: There is also a manpage of this text. You can read it with ”man mjpegtools” if installed. We also have a info version you should be able to read it with info The text version of this text is available via cvs. You should get it with the 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 Unsorted list of useful Hints You have to compile and install the mjpeg_play package, for this read the README & INSTALL.real an follow the hints from the configure script. If you do not want to compile it, you can download the mjpeg .RPM or .DEB package at Sourceforge, or if available use the one that comes with your distribution. There is a script in the scripts/ directory. This script is something that shows you a way it can be done. It also creates (under certain circumstances) videos that look quite good. Better videos you will only get by tuning the parameters. If you use a Linux kernel from the 2.4 series you will usually have to load the drivers for the Buz or DC10 or LML33 cards. 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: In the 2.6. Linux kernel is the driver for the zoran cards included, you just need to make sure that it is loaded correct. If you have a x64 machine and an kernel that is newer than 2.6.30 we'd be happy to hear that you are able to record from the zoran based card. I'm not soure if that combination works. The driver for the Matrox Marvel card also works, more information about it: 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. That is the same for the newer CPU as well. If you use specific optimizations be aware of them. 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 use v4l2 you should give mplayer a try to watch the picture 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: 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: There you also find how to create MPEG Still Images for VCD/SVCD. A good description of DV (Digital Video) can be found here:

mjpegtools(1) on Linux now