FFMPEG: setting the output resolution and bit rate depending on the input video signal

I process user videos with various proportions. FFMPEG seems to allow you to specify a fixed resolution. I want output res to be suitable for input res. Similarly, I would like FFMPEG to intelligently set the output bit based on the input video: obviously, it should not be larger than the input.

I can get video properties using

ffmpeg -i example.flv 

But this requires some ugly output analysis, so I wonder if FFMPEG or some other tool has more direct access.

Basically, I have a problem with Youtube: shit comes, reasonably uniform quality should appear.

+6
ffmpeg video
source share
4 answers

I know this is a very old question, but I would like to add my 2 cents for what it costs.

Firstly, using ffmpeg to get information about a video gives a terrible result. Try using ffprobe (bundled with ffmpeg ). You can add parameters such as -print_format json -pretty to get good JSON output, which is much easier to parse.

Check out the following article for more information: http://blog.superuser.com/2012/02/24/ffmpeg-the-ultimate-video-and-audio-manipulation-tool/ This is also a bit outdated, but should help.

+3
source share

Someone named ahaslam may already have written a short bash script that solves your problem.

+2
source share

ffmpeg has a library interface - I don’t know anything about it, but maybe you can use this to get information directly into your code?

http://www.inb.uni-luebeck.de/~boehme/using_libavcodec.html

+1
source share

Using the script seems to be the correct answer to the question I asked, but I should have mentioned that I use PandaStream. I was worried that PandaStream sets a fixed res output, but it seems to have such logic that the input video is limited to this resolution, for example. for res 480x270 output, 4: 3 video will be encoded at 360x270.

This seems like a good compromise. Just set Panda to output 16: 9 res, and then 16:10 and 4: 3 vids will work fine for most purposes.

+1
source share

All Articles