Question

i compiled the new version of FFMPEG and the padding commands have been deprecated.
As i try to get familiar with the new -vf pad= commands, i want to ask, how can i
convert a video without changing it's aspect ratio.

I've checked numerous solutions from stackoverflow, nothing seemed to work.
Can someone, please post a working PHP example or cmd line. I would be VERY happy.

Please note that the videos in question, could be 4:3 and also be 16:9

Let's say, i convert a 16:9 video to 640x480 format. It will need some bars at
the top and at the bottom. That is what i want to do.

Thanks

Was it helpful?

Solution

thanks for sharing this code.

i had to do a variation:

//keep always the same video size 
//we need to add padding and then crop the same size to keep vieos with same WxH sizes    
$command = FLV_LITE_FFMPEG_PATH . ' -i ' . $original_video;
$command .= ' -s '.FLV_LITE_VIDEO_WIDTH . 'x' .FLV_LITE_VIDEO_HEIGHT;
$command .= ' -croptop ' . $pad_top;
$command .= ' -cropbottom ' . $pad_bottom;
$command .= ' -cropleft ' . $pad_left;
$command .= ' -cropright ' . $pad_right;
$command .= ' -padtop ' . $pad_top;
$command .= ' -padbottom ' . $pad_bottom;
$command .= ' -padleft ' . $pad_left;
$command .= ' -padright ' . $pad_right;
$command .= ' -padcolor 0x000000';
$command .= ' -ab 32 -f flv -ar 22050 -b 256 -r 24 -y';   
$command .= ' ' . $converted_video; 

exec($command, $output, $status);

OTHER TIPS

Is it not possible to check what aspect ratio the video you want to convert is:

ffmpeg -i input.file

Then set this in the -aspect flag of the ffmpeg command?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top