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:
Command i ran: ffmpeg -i video.mp4 -vf scale=1280:720 output.mp4
Your current command loses the display aspect ratio.
There are 4 basic filters for video size manipulation:
scale
Scale the input video dimension. Use iw:-1
or -1:ih
to maintain the aspect ratiopad
: Add paddings to the input image (increase the frame size)crop
: Crop the input video to given dimensions (reduce the frame size)setsar
Always follow a scale
filter with setsar=1/1
to keep the pixel shape square.Read the documentation on their options and examples. You can chain these filters to accomplish your goal.
So, let's say going from a portrait video to 720p (1280x720). The first thing is to scale the input to have the height of 720px (while maintaining the aspect ratio). Then pad horizontally to fill 1280px columns. Here is the filtergraph:
-vf scale=-1:720,setsar=1/1,pad=w=1280:h=720:x=(ow-iw)/2:color=violet
You just chain these filters with commas. Note that many ffmpeg filter options accepts expressions (e.g., ow=output width, iw=input width) so you don't need to compute the exact number yourself.
Like this, just plan your sequence of actions to get the desired effect. Sketching the shape of the video after each frame will help you understand what you are doing. Good luck.