user1788736
user1788736

Reputation: 2845

How to change mp4 aspect ratio to 16:9 using ffmpeg?

I got an mp4 video that I copy 4 minute of it using ffmpeg. After uploading to YouTube I noticed the uploaded video has black bars on both side of video(right and left side)!After searching for a way to remove those black bars I found that I need to use yt:stretch=16:9!However,using yt:stretch=16.9 tag will not remove the black bars on iPhone and Samsung smart tv YouTube app!

could an expert help me change the aspect ratio of original mp4 video to 16:9 using ffmpeg (without losing video quality) for re uploading to YouTube? Thanks in advance ?

I got two types of source with following information:

1)Resolution:720x576 ,Frame rate:25 . Codec:H264 - MPEG-4 AVC(part 10)(avc1),
2)Resolution:848x480 , Frame rate:24.804393,Codec:H264 - MPEG-4 AVC(part 10)(avc1)

ffmpeg code used to trim the original video:

   ffmpeg -i orginalVideo.mp4 -ss 00:25:55 -t 00:04:02 -acodec copy -vcodec copy videoForYoutube.mp4

Upvotes: 4

Views: 23137

Answers (3)

Peterv88
Peterv88

Reputation: 185

Unfortunately none of the provided answers seemed to do the trick for me with MKV file and FFMpeg 5.1.2.

I found this simple command after some diving that does the trick converting video to 16:9 aspect ratio:

ffmpeg -i input.mkv -c copy -aspect 16/9 output.mkv

Upvotes: 4

Shakiba Moshiri
Shakiba Moshiri

Reputation: 23914

This command is also useful

ffmpeg -i input.mp4 -crf=20 -vf 'split[original][copy];[copy]scale=ih*16/9:-1,crop=h=iw*9/16,gblur=sigma=80,eq=saturation=0.9[background];[background][original]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2' output.mp4

this command unlike Gyan command expends the size of the video without stretching it and it takes more time to convert but Gyan command is faster.

source


Has been tested using ffmpeg version 3.4.8-0ubuntu0.2 on linux

Upvotes: 1

Gyan
Gyan

Reputation: 93329

Assuming the video looks acceptable after stretching, you can use the following command:

ffmpeg -ss 25:55 -t 4:02 -i input.mp4 -vf scale=ih*16/9:ih,scale=iw:-2,setsar=1 -crf 20 -c:a copy YT.mp4

Upvotes: 2

Related Questions