Good stuff for programming geeks
[ start | index | login or register ]
start > Tech Recipies > Improving MJPEG movies taken by digital cameras

Tech Recipies/Improving MJPEG movies taken by digital cameras

Created by tmoertel. Last edited by tmoertel 959 days ago. Viewed 1063 times. #6
[diff] [history] [edit] [rdf]
labels
attachments

Many consumer-grade digital cameras (like the Canon A95) can record movies in the >>Motion JPEG format, in which each frame is represented as an independent JPEG image. Most digital cameras can manipulate this format with ease because of their JPEG-processing prowess. The MJPEG format, however, does have some notable drawbacks:
  • Low compression. Because each frame is independent, inter-frame similarities cannot be "factored out" and compressed away.
  • Exaggerated noise. JPEG compression results in small noise-like artifacts that are hard to notice in a single frame but jump out in movies, where inter-frame differences are easy to see.

Re-encoding MJPEG movies to improve compression and perceived quality

To get around these problems, I re-encode my digicam's MJPEG movies using the following mencoder recipe:

mencoder input.avi -vf eq2=1.6,hqdn3d -oac copy -ovc lavc -o output.avi

The magic occurs in the video-filter specification (in bold), which comprises two post-decoding processing steps:

  • eq2=1.6 – Increases the gamma setting to 1.6, brightening the movie. (I find that movies captured indoors are often too dark.)
  • hqdn3d – Filters the video using a high-quality version of the denoise3d filter, which "aims to reduce image noise, producing smooth images and making still images really still."

To preview the effects of these filters before re-encoding with them, you can try them with mplayer:

mplayer input.avi -vf eq2=1.6,hqdn3d

QuickTime compatibility

The ffmpeg tool can be used to re-encode movies for QuickTime compatibility:

ffmpeg -i input.avi output.mp4

To avoid re-encoding artifacts, use a lossless codec in the initial mencoder step:

mencoder input.avi -vf eq2=1.6,hqdn3d -oac copy -ovc lavc -lavcopts vcodec=ffvhuff:vstrict=-1 -o temp.avi
ffmpeg -i temp.avi output.mp4
rm -f temp.avi  # the temp file can be large
no comments | post comment
community.moertel.com | Copyright © 2003–07 Moertel Consulting