摘要:我有一部几年前从 YouTube 下载的老电影,保存为 flv。我想从中提取一个 13 分钟的剪辑。为此,我使用 ffmpeg 将其转换为 mp4,这样我就可以将其加载到达芬奇中,并在其中提取了剪辑。然后我用Handbrake来压缩它。但当我这样做时,HandBrake 显着减小了帧大小,并且压缩后的剪辑与原始剪辑相比有些模糊。
为什么 HandBrake 会强制减小帧大小,以及如何让它以正确的帧大小输出?
细节:
flv 文件大小为 268 MB,持续时间 107 分钟,帧大小 318x240,帧速率 25:
我用来转换为mp4的ffmpeg命令:
ffmpeg -i input.flv -c copy output.mp4
这花了大约一秒钟的时间。结果是 264 MB:
我将其加载到 DaVinci 中,提取剪辑,然后渲染为 mp4、H.265、318x240、25 fps:
结果是 51.4 MB,13:19 mm:ss。MediaInfo 报告它是 HEVC,我理解这意味着它是 H.265,正如我所要求的:
尺寸与时间的比例比整部电影大得多:
- 电影:264 MB/107 分钟 = 2.5 MB/分钟。
- 剪辑:51.4 MB / 13.33 分钟 = 3.9 MB/分钟。
当我在 HandBrake 中加载剪辑时,它告诉我源是 318x240,25 fps。尽管它是 H.265 格式,HandBrake 告诉我它是 H.264 格式。然后,HandBrake 也与它的源信息相矛盾,在“Tracks”下说它是 30 fps,尺寸是 234x174。
========================
在 Handbrake 的“视频”选项卡中,编码器显示为 H.264,帧速率为 30。RF 为 22:
========================
我将其更改为 265 和 25:
========================
“尺寸”选项卡再次显示尺寸为 318x240,但随后又显示:
缩放后的大小和最终存储大小为234x174。我尝试单击几个内容,但无法更改输出大小。
========================
当我运行它时,输出为 22 MB,这很好地减少了文件大小:
- 压缩剪辑:22 MB / 13.33 分钟。= 1.7 MB/分钟。
但帧大小是234x174:
与原始视频相比,该视频有些模糊,这很可能是由于帧尺寸减小造成的。
由达芬奇渲染的剪辑。
这可能会为问题提供线索。图像占用的空间小于播放器的整个窗口。达芬奇是否缩小了视频的比例?
为什么 HandBrake 会强制减小帧大小,以及如何让它以正确的帧大小输出?
Edit from the questioner: I've accepted this answer because it gave me what I needed. But see further details in the additional answer that I've also given.
It may be helpful to remember that Handbrake is largely a skin for FFMPEG with some relatively user-friendly presets. Your process is currently going FFMPEG > DaVinci > FFMPEG, without any real reason we can see for the additional steps. So skip all of the intermediary steps and just use FFMPEG to clip the video. Here's another question that may cover the basics of your need: https://stackoverflow.com/questions/21420296/how-to-extract-time-accurate-video-segments-with-ffmpeg
Specify the clip start time with
-ss 00:00:00
and the end with-to 00:00:00
. Like this example from the question I've linked just above:Doing this you're removing all the possibility of issues caused by the multiple steps you're currently using.
I'm accepting the answer by "music2myear" because it gave me what I needed. But for some reason, it assumed I didn't care about the size of the output file. But I do care about that, which is the reason I was running HandBrake.
So I changed the
codec
parameter in that answer. Here is a summary of my results:Clip from DaVinci in H.265: 51.4 MB
DaVinci clip then HandBrake: 22.0 MB (blurry)
Clip from FFmpeg with
-codec copy
: 29.5 MBClip from FFmpeg with
-codec:v hevc -codec:a copy
: 15.2 MBBoth FFmpeg results appear to have good quality. The one with codec
copy
took about a second, the one withhevc
, about a minute.The result from mFFmpeg with codec
hevc
gave a very nice reduction in file size:hevc
:15.2 MB / 13.33 分钟 = 1.1 MB/分钟。所以,我不知道为什么 HandBrake(或达芬奇和 HandBrake 的组合)要减小框架尺寸。但我确实有关于如何以正确的帧大小(和有效的文件大小)获得高质量输出的答案,即直接使用 FFmpeg。
This is a work-around, rather than an exact answer: do the whole process in a single step using a GUI that gives complete control of how the output is saved.
Two free, open source, video editors, Shotcut and OpenShot (both available in Linux, and Mac, as well as Windows versions, and both Windows app run under wine, too, on this Ubuntu machine), for example, can open FLV video files, edit them, and save the edited output in various formats and with adjustable resolution and quality. There are many alternative video editors, too.
The screenshot above is from the OpenShot Export Video dialog, and ShotCut offers even more granular control of output. One selects the segments to edit, applies filters such as Sharpen, if desired, and exports with color gamut (e.g., Broadcast, MPEG or JPEG), resolution, frame rate, compression, etc. under user control, all with a single tool. Neither program is intimidating to use, since reasonable defaults are preset.