Reputation: 363
I run into a strange issue with a particular file in FFMPEG. When I try and crop it down a little I get:
[Parsed_crop_0 @ 000002ad60c27980] Invalid too big or non positive size for width '1920' or height '1040'
[Parsed_crop_0 @ 000002ad60c27980] Failed to configure input pad on Parsed_crop_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:37
Conversion failed!
This is odd to me because you can even see from the stream metadata that the resolution is much higher:
Metadata:
encoder : libebml v1.4.0 + libmatroska v1.6.2
creation_time : 2021-02-09T22:45:47.000000Z
Duration: 02:17:48.93, start: 0.000000, bitrate: 8548 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), **1920x1080** [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
There's only 1 video stream. I'm running the following command:
ffmpeg -i "wedding.mkv" -filter:v "crop=1920:1040" -c:v libx264 -preset slow -tune film -profile:v high -level 4.1 -crf 19 -c:a copy -c:s copy -map 0 "wedding-cropped.mkv"
I can preview the crop using the following command without any errors:
ffplay -i "wedding.mkv" -vf "crop=1920:960"
I've cropped a few files before without issue. I'm a bit confused as to why I'm getting a resolution error in this case when the video file is clearly higher resolution. I've also tested lowering the cropped resolution and even when I lower both by several hundred pixels it still spits out the same error. Any thoughts or suggestions?
Upvotes: 0
Views: 2136
Reputation: 808
This may be caused by metadata rotation. There's no rotate
tag in the metadata you specified in the question, but hopefully this answer will help other people.
When rotation is specified in the metadata, ffmpeg automatically rotates the video. If rotating 90 or 270 degrees, the width becomes the height and vice versa, thus the crop filter arguments are no longer correct. Adding -noautorotate
before -i
disables this behavior and fixes the problem.
Upvotes: 1
Reputation: 363
I wasn't able to work out exactly why the error was occurring but I was still able to find a solution. The video reported as 1920x1080 and even played back at that resolution but when cropping it seemed as if FFmpeg was reporting a much lower resolution. I added a scale to the video filters before the crop and that solved it. I'm still a bit unclear as to the reason it was erroring out as if it was a lower resolution but at the end of the day I was able to crop the video.
Upvotes: 1