2

I have a bunch of videos taken with my phone, and they're pretty massive given their length (eg. a 3 min video at 1920×1080 is over 400MB).

I presume this is because the phone favours battery life and quality over storage space, so I figure I could run them through Avidemux to reencode them and reduce their size while not compromising their quality too much. I realise that some degradation is inevitable. But since there's so much room for compression, I think it should be possible to avoid a great deal of perceptible degradation.

The videos are encoded in H264/AAC in an MP4 container. I can just copy the audio directly in Avidemux. But how do I deduce some approximate values for the H264 encoder to maintain the quality of the video? I don't think the H264 format keeps information about its input parameters. It's possible to choose a quality level that totally bloats the file size with no gain, and it's also possible to choose a quality level that makes the video terrible; is there some way to analyse the input to figure out a "sweet spot" where video size is reduced without affecting quality too much?

I realise that there's some degree of subjectivity in this question; what would I consider to be "perceptible" degradation? However, given that video encoders are traditionally parameterised by perceptual qualities, is it possible to come up with an approximate range for some basic parameters?

1 Answer 1

4

There are several command line or GUI tools that show some of the simplified encoding parameters of an H264 video, eg. ffmpeg or mediainfo:

$ mediainfo myvideo.mp4
[... look for the "Video" section ...]
Format profile                           : High@L4
Bit rate                                 : 17.0 Mbps

$ ffprobe -show_streams myvideo.mp4
[... look for a [STREAM] header followed by codec_type=video ...]
profile=High
level=40
bit_rate=16996359

Note the profile and level (in ffmpeg) parameters. Don't worry about the bit rate, it doesn't really tell you anything the file size doesn't. I think that the level in ffmpeg's output is 10× the real value (ie. 40 means level 4, 41 means 4.1, etc).

Avidemux allows you to use simplified settings, where you can set these and leave the finer settings at Avidemux's defaults.

Avidemux screenshot

I figured that these are the corresponding settings:

  • Use advanced configuration is unchecked.
  • Profile is high.
  • IDC Level is 4.

Using a slower Preset value will increase quality within these parameters (up to a point).

You can also use two-pass encoding to further reduce the file size. I don't know of a good way to predict a reasonable file size, but a good two-pass average bitrate for 1920×1080 is anything from 6-8Mbps. Don't target the original file size or bit rate: you'll just end up with a file of the same size.

In my case, simply doing a single pass encoding at quality level 20 (Avidemux's default) halved the file size, and comparison using Bino and Kinovea showed no difference (to me), even on motion-blurred or high contrast frames. Doing the two pass encoding at 7Mbps (which is what the single pass encode came out as) brought that down to 40%.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .