简体   繁体   English

ffmpeg输出文件太大

[英]ffmpeg output file is too large

I want to burn a subtitle file(.srt) to a mp4 video.My command is: 我想将字幕文件(.srt)刻录到mp4视频。我的命令是:

ffmpeg -i input.mp4 -c:v mpeg4 -q:v 1 -vf subtitles=input.srt out.mp4

It output a video with a good quality,but its size is 1.12GB while the input file is 213MB. 它输出质量好的视频,但其大小为1.12GB,而输入文件为213MB。

I think the problem is kbps of output file is too high.the bitrate of input file is 568 kb/s but the output file is 3154 kb/s. 我认为问题是kbps的输出文件太高。输入文件的比特率是568 kb / s但输出文件是3154 kb / s。

So I want to set the kps,now here is my code: 所以我想设置kps,现在这里是我的代码:

ffmpeg -i input.mp4 -b:v 569k -minrate 568k -maxrate 570k -c:v mpeg4 -q:v 1 -vf subtitles=input.srt out.mp4

Although the output file become smaller(538MB),the video's quality is awful(Compare with input file)... So how to make the output file smaller and in good quality?Thanks. 虽然输出文件变小(538MB),但视频的质量很差(与输入文件比较)......那么如何使输出文件更小,质量更好?谢谢。

Try this: 试试这个:

ffmpeg -i input.mp4 -c:v libx264 -crf 23 -vf subtitles=input.srt out.mp4

This uses the x264 library instead of mpeg4. 这使用x264库而不是mpeg4。 It's newer and has better compression. 它更新,压缩效果更好。 You might try playing around with the 23 being passed to the -crf option. 您可以尝试使用传递给-crf选项的23。 The Constant Rate Factor will give better results and higher file sizes at lower values, and poorer results with smaller files sizes at higher values. 恒定速率因子将在较低值时提供更好的结果和更高的文件大小,在较高值时具有较小文件大小的较差结果。 Try for something between 20 and 30. 尝试20到30之间的东西。

If you're sure you want to stick with mpeg4, this page details the options a bit more and might help. 如果您确定要坚持使用mpeg4,那么此页面会详细介绍选项并提供帮助。

And if you want to make your subtitles look nicer, take a look at the different options for subtitles , such as using different fonts. 如果您想让字幕看起来更好,请查看字幕的不同选项 ,例如使用不同的字体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM