2

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 something 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!

Steve
  • 1,857
  • 5
  • 32
  • 45
  • Hi @Steve, thanks for the accept. I'm curious, which command line options did you end up using? – Charles Mar 15 '11 at 15:16
  • I asked a similar question: http://stackoverflow.com/questions/5502654/ffmpeg-bitrate-calculation-optimization, maybe some of the answers can help. – Alix Axel Apr 04 '11 at 00:42

1 Answers1

1

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.

Charles
  • 50,943
  • 13
  • 104
  • 142