Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFMPEG: Set output res and bitrate depending upon input video

Tags:

video

ffmpeg

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.

like image 288
Jegschemesch Avatar asked Oct 17 '09 13:10

Jegschemesch


2 Answers

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.

like image 106
thorne51 Avatar answered Nov 15 '22 09:11

thorne51


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

like image 34
DaveParillo Avatar answered Nov 15 '22 10:11

DaveParillo