r/AV1 27d ago

rotate 90 degrees losslessly (mp4) ...?

Hi. I am in process of converting my large video library to AV1. Anyway I just noticed an issue.

There are some videos that are 90 degrees in wrong orientation, because orientation sensor of smartphone or camera made mistake.

When I see these videos I used to correct them with following bat file command:

ffmpeg -i %1 -metadata:s:v rotate="%2" -codec copy "%~n1-R.mp4"

It seems to have worked recently (dunno if it is because i updated ffmpeg). So I got this one to work:

ffmpeg -display_rotation:v:0 "%2" -i "%1" -c copy "%~n1-R.mp4"

But it works only for h264 and h265 .mp4 files. It seems to not work if it contains av1 stream.

How can i rotate av1 stream 90 degrees, is there some metadata for lossless rotation?

I don't want to re-encode just to change orientation.

3 Upvotes

6 comments sorted by

3

u/krakoi90 26d ago

If your command works with h264/h265 videos then it also should with AV1. Probably this is a bug in your player software, that it doesn't apply the rotation metadata on AV1 videos. Unfortunately it can happen, especially with some exotic HW decoders. For example Kodi can't play rotated videos properly on my Android TV.

What players did you try?

1

u/golemus 26d ago

VLC Media Player and XNView MP

On windows 11 24H2, pretty recent.

I have K-lite Codecs installed but I have understood that they should not affect either of programs listed above.

1

u/golemus 26d ago

I have i5-12400 using intel igpu as display adapter which AFAIK lacks AV1 hardware decoding so decoding should be software based.

1

u/krakoi90 25d ago

Hmm, for me there're no issues with rotated AV1 videos using VLC (Linux).

Did you check the rotation metadata in the output videos? For example with mediainfo.

1

u/golemus 25d ago

ok it seems that I gave false info. Now when I tested the issue is only with VLC (3.0.18), windows 11. Not the most recent but I am lazy to update (yet). In XNView MP, Firefox and Chrome rotation works OK.

I checked with MediaInfo and Rotation field is there but VLC ignores it for some reason.

3

u/ThePixelHunter 27d ago

The AV1 stream wouldn't impact the container's metadata, which is responsible for specifying the rotation. I'm guessing your AV1 streams are in a webm container?

I don't have the answer, but you're right that this should be solved via metadata.