This question might be very basic
Is there a way to reduce the frame size/rate of Lossy compressed (WMV, MPEG) format, to get a smaller video, of lesser size, with same format.
Are there any open source or proprietary apis for this?
The frame rate has a significant impact on the file size. US television has a frame rate of 30 frames per second (fps), while films in theatres are usually shown at 24 frames per second. Lowering the frame rate of your video to 15 or 10 fps can reduce the file size by as much as 200% or 300%.
You may have heard of the h. 264 codec (you may not have, but hang in there). This codec produces an MP4, which typically delivers the best quality, with smallest file size. Because of this, MP4 is very popular for web-based delivery including YouTube, Facebook, Twitter and Instagram.
ffmpeg provides this functionality. All you need to do is run someting like
ffmpeg -i <inputfilename> -s 640x480 -b 512k -vcodec mpeg1video -acodec copy <outputfilename>
For newer versions of ffmpeg you need to change -b
to -b:v
:
ffmpeg -i <inputfilename> -s 640x480 -b:v 512k -vcodec mpeg1video -acodec copy <outputfilename>
to convert the input video file to a video with a size of 640 x 480 and a bitrate of 512 kilobits/sec using the MPEG 1 video codec and just copying the original audio stream. Of course, you can plug in any values you need and play around with the size and bitrate to achieve the quality/size tradeoff you are looking for. There are also a ton of other options described in the documentation
Run ffmpeg -formats
or ffmpeg -codecs
for a list of all of the available formats and codecs. If you don't have to target a specific codec for the final output, you can achieve better compression ratios with minimal quality loss using a state of the art codec like H.264.
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