开发者

ffmpeg video encoding strategy for preventing "inflating" of low quality videos

开发者 https://www.devze.com 2023-02-16 02:20 出处:网络
We\'re trying to build a php based video sharing site that allows users to upload their own content. We need to convert all these videos into a medium-quality mp4 video file for eventual streaming th

We're trying to build a php based video sharing site that allows users to upload their own content.

We need to convert all these videos into a medium-quality mp4 video file for eventual streaming through FlowPlayer.

Our code is someth开发者_如何学Pythoning like this (example for flv):

system("ffmpeg -i $vidPath -pass 1 -ab 64k -ar 44100 -ac 1 -vcodec flv -b 1500k -cmp 3 -subcmp 3 -mbd 2 $flvPath");

The problem is that this converts any type of 1 minute video into a 10 MB file. If its a high quality 1 minute video, that gets converted to a 10 MB file - which is great. However, if its a low-quality video, say of just 2 MB, it will still get converted to a 10 MB file!!

What strategy / method should I adopt so that uploaded videos are "upper bound" in size, but lower quality videos of the same length dont get "inflated" to the same size!


It looks like you're using the -b flag to force a bitrate. What happens when you use the -minrate and -maxrate flags, as listed in the documentation instead of setting a specific bitrate?

Another interesting option is -fs, which sets a maximum file size. If you can determine the length of the video before encoding it, you can figure out what a good upper limit would be based on that length.

0

精彩评论

暂无评论...
验证码 换一张
取 消