问题描述
是否有最佳做法可以将转码的输出文件的大小保持在特定的大小?
Is there any best practice to keep the size of the transcoded output file under a specific size?
我需要将其保持在< 100 MB以下,但不知何故,我最终会输出大量输出文件。
问题是我的(测试)视频文件是600kb,而生成的output.wav 4MB。
它与我预期的相距很远。
I need to keep it under <100 MB but somehow I end up with big output files.The problem is that my (test) video file is 600kb while the generated output.wav 4MB.It is quite far away from what I expected.
var proc = new ffmpeg({
source: file,
nolog: false
});
proc.addInputOption('-acodec libopus');
format = "wav";
proc.addOptions([
'-f ' + format,
'-ab 192000',
'-ar 16000',
'-vn'
]);
这是我给ffmpeg库的参数。
我应该在这里改变哪些参数以减小大小并保持最大值。质量?
This is how I gave the parameters to ffmpeg library.What parameters should I change here to reduce the size and keep the max. quality?
推荐答案
使用WAV作为输出格式使ffmpeg选择未压缩的PCM音频,其中比特率设置不起作用。您可能想阅读这篇文章:
Using WAV as output format makes ffmpeg choose uncompressed PCM audio, where bitrate settings have no effect. You may want to read this post: What is a Codec (e.g. DivX?), and how does it differ from a File Format (e.g. MPG)?
如果您使用的是命令行,您只需将音频流复制到输出文件,而不用触摸位流( -c:a copy
):
If you were using the command line, you'd just have to copy the audio stream to an output file without touching the bitstream (-c:a copy
):
ffmpeg -i input.webm -vn -c:a copy output.opus
在流利的ffmpeg中,我想这是要走的路:
In fluent-ffmpeg, I guess this is the way to go:
ffmpeg('input.webm')
.addInputOption('-acodec libopus')
.noVideo()
.audioCodec('copy')
.output('output.opus')
您还可以 webm
作为输出格式写入 output.webm
。
You can also webm
as output format by writing to output.webm
.
这篇关于Fluent-ffmpeg如何在不丢失任何声音的情况下减小输出文件的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!