Closed bfosberry closed 1 year ago
I've been playing with pulling rotation from metadata:
const AVDictionaryEntry *entry1 = av_dict_get(fmt_ctx->metadata, "rotation", NULL, 0);
int rotation;
if ((entry1 != NULL) && (entry1->value != NULL)) {
av_log(NULL, AV_LOG_INFO, "%s = %s\n", entry1->key, entry1->value);
rotation = entry1->value;
}
and using that to conditionally set the width and height to the correct params, but it may be better to instead a) render the overlays using the specified rotation b) mark Rotation: true on the output video metadata
I’m going to study this.
I think that I rotate the frame after decoding then update metadata after encoding.
The second way is rotate each widget before draw them.
In waiting, just rotate the vidéo with ffmpeg before use gpx2video.
I think the second option makes the most sense to me
I spent a while fiddling with rotation and rotating back etc, but then I just used ffmpeg to process my video and convert it from "1920x1080 Rotation: true" to 1080x1920 Rotation: false" and your lib just works!
I think the main enhancement here would be if you detect "Rotation: true" just error with a message saying it's not supported and print out a msg saying how to convert. This is what I used:
ffmpeg -i input.mp4 -c:a copy -c:v libx264 -vf "pad=width=1080:height=1920:x=-1:y=-1:color=black" -movflags use_metadata_tags -map_metadata 0 output.mp4
Implemented
Is your feature request related to a problem? Please describe. I'm trying to add overlays to a vertical video and I've made some progress by switching height and width here and there however I am struggling to capture when a video is rotated from the metadata, and render the video correctly. I did manage to render a scrambled vertical video with the overlay correct, however Im not sure if thats the best approach.
Describe the solution you'd like I'd like to either pass flags to indicate its a vertical video, or have the system detect "Rotation" from the video metadata and correctly render the overlay.
Describe alternatives you've considered I've started manually changing code to try and find a solution but I'm struggling to transform the frames correctly
Additional context The default behavior is that the video is transformed to a horizontal video and the overlay is shown in the normal horizontal layout.