开发者

PHP FFmpeg video aspect ratio problem

开发者 https://www.devze.com 2023-01-20 14:43 出处:网络
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

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


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);


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号