0

I am using ffmpeg for rotating a video 90 degree so input this code

ffmpeg -i in.mp4 -vf "transcode=1" out.mp4

This is so slow like re-encoding. I added -c copy to make it fast but I have had an error that two function can't use at same time.

ffmpeg -i in.mp4 -c copy -vf "transcode=1" out.mp4

3 Answers 3

4

The reason it's slow is not because of the rotation, it's because you reencode the video.

When you don't specify an output video codec, the default for mp4 is H.264 (libx264) preset medium, which depending on the resolution and your hardware, can be slow.

I see you try to go around that by specifying "-c copy", but you can't : rotating the video means modifying it, so there's no way can just copy the H.264 stream. Reencoding is not an option in your case.

You can try with one of the faster presets :

ffmpeg -i in.mp4 -vf "transcode=1" -vcodec libx264 -preset veryfast -acodec copy out.mp4

But the quality/filesize will suffer.

See https://stackoverflow.com/questions/25031557/rotate-mp4-videos-without-re-encoding, there's an interesting answer about changing the metadata so that players can rotate the video.

2
ffmpeg -i in.mp4 -c copy -metadata:s:v:0 rotate=90 out.mp4

That's worked for me but not work all video player. But it is so fast than other commands. It just change the rotate flag. (Note special angle can't work with this).

1

I'm suggesting rotate instead of transcode.

ffmpeg -i input_video -vf "rotate=PI/2" output_video

Also see here and here for more information.

Hope this helps!

2
  • This option is also slow as re-encoding. The only difference between I typed and you typed is that specific angle can apply to the video via using your typed code. It re-record video. My video duration is 00:35:06 and it rotates it in 10-15 mins. Is this normal? I use always mp4 for disable re-encoding.
    – makgun
    Jul 2, 2015 at 12:46
  • 1
    Probably it will take the same time like re-encoding. Read the mentioned links for more information.
    – Chamath
    Jul 2, 2015 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .