开发者

Cropping black bars in video with ffmpeg on ubuntu changes video size

I have a source video size that's 720x576 with black rectangles on the top and bottom.

I want to remove the black rectangles and set the output video size to 640x352.

I tried -vf cropdetect and the value it gave was 640:192:0:80.

However, putting that same valu开发者_运维知识库e in crop=<parameter> changes the output video size.

How can I fix this?

E.g.:

ffmpeg -i all_the_best_test.mpg -s 640x352 -deinterlace -b 500k -minrate 500k \
-maxrate 500k -aspect 1.82 -force_fps -vcodec libx264 -me_method 10 \
-vf crop=640:192:0:80 -r 25 -acodec libfaac -ac 2 -ar 44100 -ab 96k -subq 6 \
-vpre medium /vod/Movies/final/allthebest-crop-2.mp4


When you specify -s 640x352 as the first command applying to the output, are you expecting ffmpeg will handle it last? Judging from your results, I think it must have applied it first (to the movie with the black frame still intact). So the black frame would have been resized along with the movie. Then you applied the crop that was detected for the original size movie to this new smaller movie. It's hard to explain without drawing something, but this would have distorted your aspect ratio and, if the crop is stated as the geometry to be kept, cut out some content from your margins (remember: you made the video smaller before applying the original crop). In other words, it's not just warped, but people should have some missing hair and appendages and things?

Why not make a simple test case. If I do the basic approach you have here on a black framed movie, it works very well.

Step 1 remains the same. Do ffmpeg -i movie.mp4 -vf cropdetect temp.mp4 and read what it says for crop, like your crop=640:192:0:80.

Step 2: simplify your commandline to test: ffmpeg -i movie.mp4 -vf crop=640:192:0:80 movie_without_borders.mp4. Make sure to play the result in a player that will set its own boundaries to the file size (or can be configured to do so - press 2 if you're in pot player). The new movie is not distorted and the black borders are gone.

For my test file, two size changes occurred. First, obviously, the new geometric size is what we specified for the crop. Second, the file size has slightly decreased, presumably because some small amount of space was used to preserve the black box. With libx264 and relatively compressed low quality file without much movement, cutting out a black box of equal area to the picture reduced file size from 3.99 to 3.76 (for n=1..). But most likely you meant the picture seemed 'warped.'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜