I recently programmed a bot, which uses the Twitch API to scrape Twitch videos, and then post them on YouTube. This is my youtube channel if you want to see an example: https://www.youtube.com/channel/UCuhWw8LbPWdkybIF9olAszw

The problem that I am having is I want to find a way to convert these regular twitch videos, into youtube shorts which I can automatically upload. The facecam does not need to be included, and the entire video can just be compressed into a 9:16 format.

I already tried FFMPEG but I don't know if I am doing it correctly, and really need help or advice on how to do this.

Here is an example of a video I would try to convert: https://www.youtube.com/watch?v=hZecXrvd6_g

(excuse the explicit language, this is just the first video I saw on my bot channel)

Tldr: Convert mp4 file into a 9:16 video format

Edit: FFMPEG command I ran: ffmpeg -i video.mp4 -vf scale=1280:720 output.mp4

Thank you so much in advance! This has been bugging me for days.

3 Answers 3


scale will resize the video. To change the aspect ratio you can try something like:

ffmpeg -i video.mp4  -vf setdar=9/16 output.mp4

Crop the clip to 9/16 like this:

ffmpeg -i video.mp4 -vf crop=ih*(9/16):ih output.mp4

Youtube Shorts' maximum length is 60 seconds. You can split and resize the video into segments using this command.

ffmpeg -i video.mp4 -ss 00:00:00 -t 00:01:00 -vf "[in]scale=iw*min(1080/iw\,1920/ih):ih*min(1080/iw\,1920/ih),pad=1080:1920:(1080-iw)/2:(1920-ih)/2[out]" newVideo.mp4

This command will cut the 1st minute, in order to cut other sections you should write some math logic to calculate and do it. Already I did it for PHP, check below: https://gist.github.com/drpshtiwan/45fd233695b168056af980c56b93579c


Or you should overlay the split video (newVideo.mp4) into a background video which should have a black background, 60 seconds duration, and a 9/16 ratio. This is ffmpeg command to do the magic ;) I used a full HD video and I overlaid the video in the center.

ffmpeg -i background.mp4 -i newVideo.mp4 -filter_complex "[1:v]scale=1080:-1[v2];[0:v][v2]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -map 1:a  -c:v libx264 -c:a  copy shortVide.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.