Reduce video size in the same format and reduce frame size

This question can be very simple.

Is there a way to reduce the size / frame rate of the Lossy compression format (WMV, MPEG) in order to get smaller video with a smaller size in the same format.

Is there any open-source or my own apis for this?

+42
video compression video-processing
Dec 20 '10 at 13:39
source share
3 answers

ffmpeg provides this function. All you have to do is run as

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 video with a size of 640 x 480 and a bitrate of 512 kilobits per second using the MPEG 1 video codec and simply copying the original audio stream. Of course, you can connect any values ​​you need and play with the size and bit rate to achieve the desired quality / size. There is also a ton of other options described in the documentation.

Run ffmpeg -formats or ffmpeg -codecs for a list of all available formats and codecs. If you do not need to configure a specific codec for final output, you can achieve higher compression ratios with minimal loss of quality using a modern codec such as H.264.

+62
Dec 20 '10 at 16:02
source share

If you want to keep the screen size the same, you can use the crf coefficient: https://trac.ffmpeg.org/wiki/Encode/H.264

Here is a command that works for me: (on a Mac, you need to add -strict -2 to use the aac audio codec.

 ffmpeg -i input.mp4 -c:v libx264 -crf 24 -b:v 1M -c:a aac output.mp4 
+20
Aug 27 '14 at 12:39 on
source share

Instead of using fixed data rates with the H.264 codec, you can also choose a different preset, as described in https://trac.ffmpeg.org/wiki/x264EncodingGuide . I also found Comparison of the video encoder on the KeyJ blog ( archived version ) an interesting read, it compares H.264 with Theora and others.

Below is a comparison of the various options that I have tried. The recorded video was originally 673M in size, made on an iPad using RecordMyScreen . It has a duration of about 20 minutes with a resolution of 1024x768 (while half the video is not full, so I cut it to 768x768). To reduce the size, I lowered the resolution to 480x480. No sound.

The results are based on 1024x768 (and using cropping, scaling and filter ):

  • Without special options: 95M (encoding time: 1m19s).
  • With the addition of only -b 512k size dropped to 77M (encoding time: 1m17s).
  • Only -preset veryslow (and not -b ), it became 70M (coding time: 6m14s)
  • When using -b 512k and -preset veryslow size becomes 77M (100K less than just -b 512k ).
  • With -preset veryslow -crf 28 , I get a 39M file that occupied 5m47s (without visual quality for me).

N = 1, so take the results with salt and do your own tests.

+16
Dec 01 '13 at 23:02
source share



All Articles