FFMPEG:裁剪视频而不损失质量 [英] FFMPEG: crop a video without losing the quality
问题描述
我有mp4视频 1920x1080
。我想将视频裁剪到 480x270
而没有质量损失。
我是使用以下命令:
ffmpeg -i input.mp4 -filter:vcrop = 480:270:200:200 -crf 23 output.mp4
我也试过:
$ b $ -c:一个副本-qp 0 output.mp4
$ b $ / code>
我使用了 -crf 23
和 qp 0
用于无轨迹视频裁剪,但裁剪后的视频质量下降。
有谁知道如何裁剪视频而不会丢失的质量?
编码到有损格式时,您不能执行任何过滤,而不会损失质量,但您有一些选项。
您的播放器播放
可能的解决方案是播放时裁剪,因此您甚至不需要重新编码。
使用 ffplay
和作物过滤器:
ffplay -vfcrop = 480:270:200:100 input.mp4
使用 vlc
(或
vlc input.mp4 --crop = 480x270 + 200 + 100
或者您可以使用VLC GUI裁剪:工具>效果&过滤器>视频效果>裁剪
使用无损格式
ffmpeg
可以编码几个无损编码器:ffv1,huffyuv,ffvhuff,utvideo,libx264(使用
-crf 0
或 -qp 0
)。输出将是无损的,但输出文件将是巨大的。
ffmpeg -i input.mp4 -vfcrop = 480: 270:200:100-c:v ffv1 -c:a copy output.mkv
或
ffmpeg -i input.mp4 -vfcrop = 480:270:200:100-c:v libx264 -crf 0 -c:copy output.mp4
接受一些质量损失
给它足够的位,你可能无法知道质量差异:
ffmpeg - 我输入-vfcrop = 480:270:200:100-c:v libx264 -crf 17 -c:a copy ouput.mp4
请参阅 FFmpeg Wiki:H.264视频编码指南更多信息
如果您的输入是MJPEG
使用 ffmpeg
复制单个图像,裁剪他们失利稍微用 jpegtran
,然后用 ffmpeg
重新配置它们。这将导致没有损失,但您将被限制在古代MJPEG格式。
I have mp4 video of 1920x1080
. I would like to crop the video to 480x270
without quality loss.
I am using the following command:
ffmpeg -i input.mp4 -filter:v "crop=480:270:200:200" -crf 23 output.mp4
I also tried:
ffmpeg -i input.mp4 -filter:v "crop=480:270:200:100" -c:a copy -qp 0 output.mp4
I used -crf 23
and -qp 0
for loseless video cropping, but after cropping video has lost quality.
Does anyone know how I can crop the video without losing the quality?
You can't perform any filtering without losing quality when encoding to a lossy format, but you have some options.
Crop with your player
A possible solution would be to crop during playback, so you don't even need to re-encode.
With ffplay
and crop filter:
ffplay -vf "crop=480:270:200:100" input.mp4
With vlc
(or cvlc
):
vlc input.mp4 --crop=480x270+200+100
Or you could crop with the VLC GUI: Tools > Effects & Filters > Video Effects > Crop.
Use a lossless format
ffmpeg
can encode with several lossless encoders: ffv1, huffyuv, ffvhuff, utvideo, libx264 (using -crf 0
or -qp 0
). The output will be lossless but the output file will be huge.
ffmpeg -i input.mp4 -vf "crop=480:270:200:100" -c:v ffv1 -c:a copy output.mkv
or
ffmpeg -i input.mp4 -vf "crop=480:270:200:100" -c:v libx264 -crf 0 -c:a copy output.mp4
Accept some quality loss
Give it enough bits and you may not be able to tell there is a quality difference:
ffmpeg -i input -vf "crop=480:270:200:100" -c:v libx264 -crf 17 -c:a copy ouput.mp4
See FFmpeg Wiki: H.264 Video Encoding Guide for more info.
If your input is MJPEG
Stream copy the individual images with ffmpeg
, crop them losslessly with jpegtran
, then remux them with ffmpeg
. This will result in no loss, but you will be restricted to the ancient MJPEG format.
这篇关于FFMPEG:裁剪视频而不损失质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!