Transcoding Motion-JPEG (.MOV) to MPEG-4 (H264)


please see => Newer Approach


I have a Panasonic DMC-ZS5 (dpreview, Panasonic) which creates .MOV files that contain the Motion JPEG (M-JPEG) “format” (for want of a more technical term).

In order to stream those videos from my IIS/PHP based photo gallery (, they must be converted to a more “web compatible” format like MPEG-4.  I haven’t found a more straightforward approach than direct batch conversion to another format… you can readily automate the conversion of say all the videos in a folder so it’s pretty much turnkey and ignore.

Update 2015-01-05: This is my current go-to:


  • make sure to double up all the %%v if you put in .cmd batch file
  • ffmpeg is a very popular 3rd party command line util. I get mine from here.

Update 2015-07-18: cropping 3D movies down to single image

  • obviously check the real resolution before setting the crop… just divide it by 2
  • “setdar” is the aspect ratio… i found it was necessary… one way to find it is with VLC CTRL-J on the original video

VLC will do this via a command line like so:


  • I’ve had to remove the acodec=mpga for my iPhone MOV’s or else I get garbled audio.
  • I included the vfilter=”rotate…” for rotation syntax since it was so hard for me to find but only include if you want rotation.

However, I noticed that VLC chops off the last 2 seconds no matter what I do… it seemed a little better choosing a different vcodec but h264 is too rocking to use anything else.

So I wound up going with QuickTime as my go-to transcoder for now.  It doesn’t truncate any video and creates a slightly smaller output file than VLC.  The compression is dramatic and h264 does an awesome job with preserving quality… even while maintaining 1280 x 720 HD, a 100MB MJPG will go down to a 5MB h264/MPEG file.

Following code stolen from here and tweaked a little, automates the QuickTime COM API to convert a directory full of MJPG’s (see sample code for Chapter.8 > “BatchExport.js”).

There’s no reason why this shouldn’t be in PowerShell… it’d be interesting to see if it was any more readable.