1

I'm using FFMPEG to re-encode some videos, while rotating and shrinking them.

Which one should I do first, considering:

  • Output quality
  • Output size
  • Encoding speed

I am aware I can rotate without any reencoding, but that's beside my point.

Destroy666
  • 12,350
user541686
  • 23,629

1 Answers1

0

Encoding speed

This one is kind of obvious. Rotation doesn't reduce number of pixels while shrinking does. The process of rotating a smaller video will always be relatively faster. Shrinking a rotated video will have more or less the same time as if it wasn't rotated.

Output quality

Rotating a bigger video or image should always result in higher quality of rotation with reencoding. Especially for rotations that aren't standard 90, 180, 270 degree ones. The more pixels there are to work with, the more accurate the end result will be.

Output size

I don't think it matters too much for output size either way. There might be minimal differences that come from quality changes mentioned above, but this shouldn't be your main focus, even when working with big videos. The deviations shouldn't be huge.


You can always quickly test this yourself. This is an example comparison for H.264 MP4 with the following commands:

ffmpeg -i input.mp4 -vf transpose=2 output1.mp4
ffmpeg -i output1.mp4 -vf scale=iw/2:ih/2 output1f.mp4
ffmpeg -i input.mp4 -vf scale=iw/2:ih/2 output2.mp4
ffmpeg -i output2.mp4 -vf transpose=2 output2f.mp4

In my case, with a ~60 MB file for output1f.mp4 (rotation first) it was:

  • ~29 s for rotation + 9 s for reducing size
  • ~3.5 MB size
  • very similar quality

And for output2f.mp4 (shrinking first):

  • ~9 s for reducing size + ~7 s for rotation
  • ~3.4 MB size
  • very similar quality

So the speed was noticably better for shrinking first, the file size just slightly better for that too and the quality wasn't too different for my eyes, although of course a little smaller file size suggests a little bit of quality loss and it would differ more with more complex files and rotations.

Destroy666
  • 12,350