Sunday, October 27, 2013

Fix for ffmpeg Resulting Movie is Flipped Vertically or Horizontally

Symptom:

I had to assemble a movie clip using ffmpeg from individual JPEG frames. In my situation I wanted to make both .ogg and .mp4 medical cine clips that can be shown directly on HTML5 web browsers.

The movie makes fine but the only issue is that the movie images are all vertically flipped.

I still do not know why the images are encoded flipped since when I view individual image using Windows Preview or other JPEG viewers, I do not get the orientation issue. It is likely though these have missing Exif header which does have orientation information that's usually supplied from cameras.

At any rate, this can actually be corrected easily.

Fix:

ffmpeg contains filters and you can do a very complex filter operations. One of the operations is flipping.

By supplying

-vf "hflip"

I can horizontally flip all frames in the movie.

-vf "vflip" does the vertical flip

and

-vf "hflip, vflip" can do both.


Post a Comment