Fluent-ffmpeg how to reduce the size of the output

2019-09-16 23:32发布

Is there any best practice to keep the size of the transcoded output file under a specific size?

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'
    ]);

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?

1条回答
欢心
2楼-- · 2019-09-16 23:57

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)?

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

In fluent-ffmpeg, I guess this is the way to go:

ffmpeg('input.webm')
  .addInputOption('-acodec libopus')
  .noVideo()
  .audioCodec('copy')
  .output('output.opus')

You can also webm as output format by writing to output.webm.

查看更多
登录 后发表回答