Opened 5 months ago
Closed 5 months ago
#11038 closed defect (invalid)
bsf 'rotate' seemingly not doing anything
Reported by: | geegee | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | git-master | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
FFMPEG is not changing the rotation matrix when asked to like when for example using either of the two sample commands provided below. The two output files will be identical to each other and even to a third simple output made with ffmpeg -i input.mp4 -c copy outputx.mp4
, meaning -bsf:v h264_metadata=rotate=90.0
and -metadata:s:v:0 rotate=90
aren't doing anything at all. This can be further verified by opening the output file(s) in a hex editor and checking the values of the rotation matrix as specified in this external post: https://superuser.com/a/1307206/580856
Outputs will lack the line displaymatrix: rotation of 90.00 degrees
when analized with ffprobe, but this line will be displayed when the mp4 is edited manually with a hex editor as specified in the superuser link.
How to reproduce:
% ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output2.mp4
or
% ffmpeg -i input.mp4 -c copy -bsf:v h264_metadata=rotate=90.0 output1.mp4 ffmpeg version 2024-04-04-git-478d97f303-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers built with gcc 13.2.0 (Rev5, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 59. 13.100 / 59. 13.100 libavcodec 61. 5.101 / 61. 5.101 libavformat 61. 3.100 / 61. 3.100 libavdevice 61. 2.100 / 61. 2.100 libavfilter 10. 2.101 / 10. 2.101 libswscale 8. 2.100 / 8. 2.100 libswresample 5. 2.100 / 5. 2.100 libpostproc 58. 2.100 / 58. 2.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf59.27.100 Duration: 00:10:50.38, start: 0.000000, bitrate: 1830 kb/s Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 888x1920 [SAR 1:1 DAR 37:80], 1691 kb/s, 43.14 fps, 43 tbr, 15360 tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] encoder : Lavc59.37.100 libx264 Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] [h264_metadata @ 0000012096b317c0] 4 bytes left at end of AVCC header. Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Output #0, mp4, to 'output1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf61.3.100 Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 888x1920 [SAR 1:1 DAR 37:80], q=2-31, 1691 kb/s, 43.14 fps, 43 tbr, 15360 tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] encoder : Lavc59.37.100 libx264 Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] Press [q] to stop, [?] for help [out#0/mp4 @ 0000012096b53900] video:134242KiB audio:10163KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.634229% size= 145321KiB time=00:10:50.27 bitrate=1830.7kbits/s speed= 881x
The h264_metadata bsf modifies the bitstream (i.e. it adds a SEI message that indicates the rotation), not the displaymatrix as used by mov/mp4.
The metadata rotate tags have been removed (after having been deprecated for ages). Use the display_rotation ffmpeg option instead.