.

.
.
.
.
.
.
.
. scroll down
.
.

Monday, July 19, 2010

Shrink your video files

2010-7-19 15.11
Why would you want to re-compress you video files?
Well, I don´t know about you, but with the quality the Sony HX5 gives me in videos, I find myself using the video function more and more. And that shows on my disk. Where before a DVD was enough to archive several years of picture memories including some clips, now a DVD would be filled in a matter of weeks.
So I need a way of keeping the videos I want but if I could get them smaller without loss of visible quality that would be perfect.
After spending several days work to try all kinds of programs and fiddle with the settings to get exactly the results the way I wanted it it is time to share that information with you. In one sentence: You can save 50 to 75% of space and keep a good quality.
 
If you have lots of movement over most of the screen, then re-compression might not save you much. This 3 min clip "Fiesta del Carmen Gran Canaria 2010 - Sony HX5.MP4" in the original is 150 Mb re-compressed with RF:25 (see below) brought the file down to 132 Mb. In a case like this you already got the best compression / quality ratio in the original file.


If you have a mostly static scene like on this 32 second clip a small grasshopper drinking, you can archive a compression from the original 24 Mb to 3.3 Mb at setting RF:25 what is quite a lot for nearly the same quality.


Now, how is it possible to compress one file so much and another nearly not at all?
Coming from over 10 years of getting video clips to the computer starting with VHS-C, the Snappy to grab images out of the videos and the DAZZLE with a parallel port to encode to REAL Media with QVGA in the last Millenium we have come a long way and the two pass encoding in AVI is so yesterday.



From the HandBrake wiki:
With the average bitrate or target size methods, you control the size of the output file but give up control over the video's quality.

Constant quality mode does the opposite; you specify a quality level and HandBrake adjusts the bitrate (that is, the size) to meet it.
Because it takes a different bitrate to reach a given quality level for any given part of any movie, the output size is unpredictable and varies from source to source. 

I will show you how you can easy decide what quality YOU like and how you can shrink all your video files quite a bit and always have the same quality.
Before we finally start, here a sample from a HD encoding with the old 2 pass method. If you have extremely fast flashing of pictures during a scene, two pass just can not handle the fast changing amount of information.
The result is a quality like this:

  In constant quality mode this part of the movie would be as sharp and without noticeable compression artifacts. And this is why you should spread the word about HandBrake and the gorgeous constant quality mode you can use to compress your video files.



First let´s take a short trip to France.
Go visit the makers of Handbrake and get a free copy. You can have it for: Mac OS, Windows, Ubuntu and Fedora 12
If you want to have the newest version from Handbrake, check out the nightly builds.
Install and run it. Drag and drop a video file into it.


Beginner
SETTINGS
:
Video Filters - If you recorded in AVCHD set Decomb to Default. If you recorded in MP4, skip this step.
Video - Now comes the decision how good the quality YOU are desire has to be. The lowest acceptable level for me is RF 32 @ Constant Quality, RF 28 is a good balance for size and quality.
Audio - no change
Presets - Regular Normal
Destination - choose where you want to have the re encoded video
press the green Start button

Advanced
SETTINGS
:
Picture - if you want to have your video in 4:3 set Cropping to Custom and 160 for left and right
Video Filters - If you recorded in AVCHD set Decomb to Default. If you recorded in MP4, skip this step.
Video - Now comes the decision how good the quality YOU are desire has to be. The lowest acceptable level for me is RF 32 @ Constant Quality, RF 28 is a good balance for size and quality. For a nice quality RF 25. If you go up to RF 20 and above,  you will have nearly the same size than the original.
Audio - no change
Presets - Regular High Profile This encodes slower but more precise, the file gets a bit bigger also.
Advanced - for even more precise encoding copy and paste in the bottom box:
ref=6:mixed-refs=1:bframes=3:b-pyramid=1:weightb=1:subq=7:trellis=2:analyse=all:8x8dct=1:no-fast-pskip=1:no-dct-decimate=1:me=umh:merange=64:deblock=-2,-1:direct=auto
Destination - choose where you want to have the re encoded video
press the green Start button

Let us see how we can get the smallest file size with the quality you want.

Under the Hood
If you want to do some testing for your self, cut 10 seconds of your favorite video. Take a part where you have a steady  object and a part where there is lots of movement. If you do not have that, just grab something quick with your camera. Why only 10 sec? Because it takes a lot of time to encode if you want to test things for yourself.
Here are some of my results:
Since in some parts of our globe a breast and especial an uncovered nipple is a taboo I decided to crop the screen grabs to keep you poor folks sane.
Here is what to look out for:
The compression artifacts will appear first on the painters upper arm, also look at the mesh of her top for compression smearing. The face and the eyes of our model and the contour of the face to the water are an indicator for the sharpness, or loss of.



Original file 720p - 16 sec - 12 Mb

H.264 codec

RF:20 - Normal - 13 Mb - excellent


RF:23 - Normal - 9 Mb - excellent


RF:25.5 - Normal - 6 Mb - excellent


RF:28 - High Profile - 4.8 Mb - good


RF:28 - Normal - 4.4 Mb - good


RF:30.5 - High Profile - 3.3 Mb - good


RF:30.5 - Normal - 2.9 Mb - OK


RF:33 - Normal - 1.9 Mb - starting to loose detail and compression artifacts visible


RF:35.5 - Normal - 1.4 Mb -  bad



RF:32 -Normal - 2.3 Mb - starting to loose detail


RF:32 - High Profile - 2.7 Mb - OK


RF:32 - High Profile extreme setting, see above- 2.9 Mb - OK



MPEG-4 codec
QP:8 - Normal - 8.2 Mb


QP:10 - Normal - 6.2 Mb


QP:12 - Normal - 4.9 Mb

1 comment:

  1. nice i was searchin for wat rf was da post was great thnx:-)

    ReplyDelete