MJPeg (or "motion jpeg") is a video encoding format. It's very very large, and not very good at storing video in a space effecient manner. Each frame is a jpeg image, and is store alone, independent of each the precedding and following frame.
This is unlike other video formats which will pay attention to the flow of frames.
However, since mjpeg is so simple to encode to, it is very fast. If you are streaming a video, and you need to save it live, and you don't have enough CPU power to encode it live to a better format, or enough harddisk bandwidth to save it raw, then mjpeg is a great format to save it to. This should prevent dropped or missing frames from interfering with your video (and possibly causing skipped playback or audio/video (a/v) sync problems.
Motion JPEG with gstreamer is very easy, just use the
jpegenc element. A good container/muxer is avi, so use
Sample gst launch example:
gst-launch-0.10 …someinput elements… ! jpegenc ! avimux ! filesink location=video.avi
gst-launch-0.10 v4l2src ! ffmpegcolorspace ! jpegenc ! avimux ! filesink location=video.avi
This will record from a v4l2 (video4linux 2) device, encode to mjpeg and dump it to an avi file called video.avi.
Container format and audio format
When playing around with mjpeg and jpegenc, I had a lot of problems with picking the right muxer & audio format. There were loads of muxers that you could not put a jpegenc into, avi's work well. However if you have avi & jpegenc, there are lots of audio formats that you can't use with it. You'll see errors from gst-launch like "cannot link jpegenc0 to mux".
'audio/x-raw-int,rate=44100,channels=2' as a cap on the audio format works well.
So a pipeline like this works well:
gst-launch-0.10 v4l2src ! video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! jpegenc ! queue ! avimux name=mux ! filesink location=video.avi pulsesrc ! audioconvert ! 'audio/x-raw-int,rate=44100,channels=2' ! mux.
That will record from a v4l2 source, convert to mjpeg, and at the same time record from a pulse audio microphone and save that to video.avi. This will be a very large file, since there is very little compression going on.
It should convert to audio to 2 channel (i.e. stereo sound) at 44.1kHz. Feel free to play around with these figures to see what works.