Skip to content

Problem with MP4/H264 metadata crop values

I have Ubuntu 20.04 Mate, VLC 3.0.9.2, MPV 0.32.0, MPlayer 1.3.0, AVIdemux 2.7.6. I know you will say this version of VLC is outdated and no longer supported, but that's the version I get from the repository for this version of Ubuntu. Maybe someone else can test this issue with the most recent version of VLC.

I have a video file (H264/AAC/MP4) in 16:9 aspect (1024x576p) where the video was accidentaly horizontaly squeezed to 4:3 and letterboxed with black bars at the right and left sides to fill the full 16:9 frame size. I didn't want to re-encode it, so I tried to use MP4 metadata to correct the squeezing and remove the black bars. To do so, I used these two ffmpeg commands:

ffmpeg -i inputfile.mp4 -aspect 235:100 -c copy outputfile.mp4

ffmpeg -i inputfile.mp4 -bsf:v h264_metadata=crop_left=128:crop_right=128:crop_top:0:crop_bottom=0 -codec copy outputfile.mp4

I opened the resulting file with VLC 3.0.9.2, MPV 0.32.0, MPlayer 1.3.0, and AVIdemux 2.7.6 and this was the result:

  • Only MPlayer showed the new aspect ratio and cropped both sides correctly.
  • AVIdemux ignored the new aspect ratio but cropped both sides correctly.
  • MPV showed the new aspect ratio but left the left side uncropped, only the right side was cropped correctly.
  • VLC showed the new aspect ratio but left the left side uncropped, the right side was cropped but not correctly (it seems that the left value was added to the right value).

I will add a screenshot.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information