0

I'm using the following command:

ffmpeg -i port001.jpg -vf "scale=100:-1" /tmp/1/port_converted_100-1.jpg

It is working fine on landscape pics but it automatically rotate the portrait pics. Any idea how to avoid the rotation?

davidbaumann
  • 2,289
Benny
  • 1

1 Answers1

0

The exif Orientation tag is ignored by ffmpeg

This is ticket #6945: ffmpeg fails at jpeg EXIF orientation.


Rotate your images before using ffmpeg*

Manually

jpegtran can be used to losslessly rotate images. You can use it manually to rotate or create a script to rotate based on the Orientation tag.

jpegtran -rotate 90 input.jpg > output.jpg

Note that this will strip some of the exif data. If you want to keep it all add -copy all then remove the now incorrect Orientation tag with exiftool:

exiftool -Orientation="" output.jpg

With exifautotran

This tool with automatically re-orient the images according to the Orientation tag:

mkdir images
cp *.jpg images
cd images
exifautotran *.jpg

* If ticket #6945 is fixed then this method will become moot.

Viewing exif orientation tag in JPG image

You can use exiftool to view the orientation:

$ exiftool -Orientation -S image.jpg
  Orientation: Rotate 90 CW
$ exiftool -Orientation -n -S image.jpg
  Orientation: 6

Now you can scale with ffmpeg

ffmpeg -i input.jpg -vf "scale=100:-1" output

For more fancy scaling see Resizing images with ffmpeg to fit into specific sized box.

llogan
  • 63,280