Skip to content

Incorrect cropping via h264_metadata. #16758

@Sopel97

Description

@Sopel97

mpv Information

mpv v0.40.0-298-gb9ceaf243 Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
 built on Sep  2 2025 20:14:12
libplacebo version: v7.354.0 (v7.351.0-67-g515da95-dirty)
FFmpeg version: N-120956-gc2ce38738
FFmpeg library versions:
   libavcodec      62.15.100
   libavdevice     62.2.100
   libavfilter     11.8.100
   libavformat     62.4.102
   libavutil       60.11.100
   libswresample   6.2.100
   libswscale      9.3.100

Other Information

- Windows version: Microsoft Windows [Version 10.0.22631.4317]
- GPU model, driver and version: NVIDIA RTX 4070 Super, 552.12
- Source of mpv: https://github.com/zhongfly/mpv-winbuild/releases
- Latest known working version: no known working version
- Issue started after the following happened: no known working version

Reproduction Steps

ffmpeg -y -f lavfi -i testsrc=size=1920x1080 -t 10 -pix_fmt yuv420p testsrc.mp4
ffmpeg -y -i testsrc.mp4 -map 0 -c copy -bsf:v h264_metadata=crop_left=240:crop_right=240 testsrc_cropped.mp4
mpv testsrc_cropped.mp4

Produced file is

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'testsrc_cropped.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf62.4.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 172 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1440x1080 [SAR 1:1 DAR 4:3], 169 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc62.13.101 libx264

Expected Behavior

Cropping via h264_metadata is precise.

Actual Behavior

Crops 192 pixels from the left, 240 from the right. The amount of pixels cropped seems to always be a multiple of 16, with no clear rounding.

Log File

output.txt

Sample Files

No response

I carefully read all instruction and confirm that I did the following:

  • I tested with the latest mpv version to validate that the issue is not already fixed.
  • I provided all required information including system and mpv version.
  • I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • I attached the full, untruncated log file.
  • I attached the backtrace in the case of a crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions