FFMPEG: Set output res and bitrate depending upon input video

ffmpeg, video

Solution

I know this is a very old question, but I'd like to add my 2 cents for what its worth.

Firstly, using `ffmpeg` to get info on the video does give ugly output. Try using `ffprobe` (bundled with `ffmpeg`) instead. You can add options like `-print_format json -pretty` to get nice JSON output of the information, which is much easier to parse.

Additionally, have a look at the following article: http://blog.superuser.com/2012/02/24/ffmpeg-the-ultimate-video-and-audio-manipulation-tool/ Its also a bit dated but should help as well.

Problem

I'm processing user videos with differing aspect ratios. It seems FFMPEG only allows you to specify a fixed resolution. I want the output res to be appropriate for the input res. Similarly, I'd like FFMPEG to intelligently set the output bitrate based on the input video: obviously it shouldn't be any bigger than the input. I can get the properties of a video with, ``` ffmpeg -i example.flv ``` But this requires some ugly parsing of the output, so I'm wondering if FFMPEG or some other tool has a more direct facility. Basically, I have the Youtube problem: crap comes in, reasonably uniform quality should come out.

Original source