[FFmpeg-devel] [PATCH] ffmpeg: set user-set rotation for encoded streams too

Gyan Doshi ffmpeg at gyani.pro
Tue May 10 14:40:54 EEST 2022


So far, -metadata:s:v rotate would only be applied to streamcopied
video streams.
---
 fftools/ffmpeg.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index a85ed18b08..7c1db2162a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3048,6 +3048,13 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
             av_reduce(&ost->frame_rate.num, &ost->frame_rate.den,
                       ost->frame_rate.num, ost->frame_rate.den, 65535);
         }
+
+        if (ost->rotate_overridden) {
+            uint8_t *sd = av_stream_new_side_data(ost->st, AV_PKT_DATA_DISPLAYMATRIX,
+                                                  sizeof(int32_t) * 9);
+            if (sd)
+                av_display_rotation_set((int32_t *)sd, -ost->rotate_override_value);
+        }
     }
 
     switch (enc_ctx->codec_type) {
-- 
2.36.1



More information about the ffmpeg-devel mailing list