I have videos with different resolution. I want that all of them will be in resolution of 480x320. I tried the command:
ffmpeg -i %s_ann.mp4 -vf scale=480x320,setsar=1:1 %s_annShrink.mp4' %(dstfile,dstfile)
but the output of the videos are files with the size of 0 kb.
What I'm doing wrong?
Download and set up FFmpeg on your computer, use command line to compress video with FFmpeg by changing video codec format, lowering down bitrate, cutting video length, etc. For example, set CRF in FFmpeg to reduce video file size (ffmpeg -i input. mp4 -vcodec libx264 -crf 24 output.
To set the bitrate target in FFmpeg, use the -b:v code (bitrate:video) below : ffmpeg -i Test_1080p. MP4 -c:v libx264 -b:v 5000k Test_DR_5M.
How to easily upscale a 1080p video to 4k resolution using FFmpeg and a one-line command. The speed of the video upscale will depend on the video length, bitrate, your CPU and what settings you use for the upscale process.
I guess that really there are two questions here...
These scripts ought to do the trick...
Windows
for %%i in (*.mp4) do ( ffmpeg -y -i "%%i" << TODO >> "%%~ni_shrink.mp4" )
Linux (UNTESTED!)
for i in *.mp4; do ffmpeg -y -i "$i" << TODO >> "${i%.mp4}_shrink.mp4"; done
(I'm not too sure about the output file expansion in the Linux script, worth validating that.)
This is a little trickier. As you have your command, the aspect ratio is potentially going to get messed up. Options here...
Option 2 would be the preferred solution, otherwise you are (probably unnecessarily) increasing the output file size. Option 3, I'll give a partially tested solution. Option 4 I'm not even going to touch.
Option 2: Scale the video, keep aspect ratio so that height is adjusted to fit
ffmpeg -y -i "%%i" -vf scale=480:-2,setsar=1:1 -c:v libx264 -c:a copy "%%~ni_shrink.mp4"
Option 3: Scale the video, keep aspect ratio and pad with black bars so that the video size is exactly 480x320
ffmpeg -y -i "%%i" -vf "[in]scale=iw*min(480/iw\,320/ih):ih*min(480/iw\,320/ih)[scaled]; [scaled]pad=480:320:(480-iw*min(480/iw\,320/ih))/2:(320-ih*min(480/iw\,320/ih))/2[padded]; [padded]setsar=1:1[out]" -c:v libx264 -c:a copy "%%~ni_shrink.mp4"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With