
Video rip. Part 3. Compress and pack
Content
- DVD preparation
- Video processing
- What is interlace and what does it eat
- How to determine what we have: progressive, interlaced or telecined?
- Getting rid of regular interlacing (deinterlace)
- IVTC
- Squeeze and pack
The latest article in their Video rip series. I’m even a little sad that it was all over, but I finally closed the gestalt and now I won’t have dreams about how the habralum asked me to complete what I started.

Today we will learn how best to compress, in which format, which container to use and with which utilities. This part will be the simplest and to some extent general education.
So, for a start we will define a little with terms.
A container is such a thing where we can put video and / or audio, which is compressed by some algorithm. Examples of popular containers are AVI, MKV, MP4, OGM. Streams of different formats can be in one container.
Compression algorithm (format) - an algorithm that compresses video or audio, which will then be placed in a container.
Examples of video compression formats:
- MPEG-4 AVC [aka H.264] (encoder implementations: x264, Apple H.264, Videosoft H.264, Elecard H.264, Intel IPP H.264, MainConcept H.264, etc. );
- MPEG-4 ASP (encoder implementations: DivX, XviD, libavcodec, etc.);
- Ogg Theora (encoder implementation: libtheora).
Examples of audio compression formats:
- MPEG Layer-3 [aka MP3] (encoder implementations: LAME, Fraunhofer IIS MPEG Layer-3 Audio, etc.);
- MPEG-4 AAC (encoder implementations: Apple AAC, FAAC, etc.);
- AC3 [aka Dolby Digital, A / 52] (encoder implementations: liba52 etc.);
- Ogg Vorbis (libvorbis).
Some threads cannot be put in some containers. For example, without various kinds of tricks, you will not be able to put H.264 into AVI. Here, for example, in the Russian doll (MKV) you can put almost everything.
Compression
I recommend that you always use H.264 compression to compress the video stream. As a specific implementation of the H.264 encoder, I chose the open source x264. Those who say: “Here they only need to compress HD video, but the rest is not necessary, XviD is enough,” I believe, are fundamentally wrong.
H.264 versus MPEG-4 ASP (DivX / XviD) is the next generation compression standard. Specifically, x264 has a bunch, just a ton of settings that allow you to compress any video, very finely adjusting the hardware powers necessary for decoding and encoding. You can set the settings in such a way that the same video can slow down, or maybe not.
It may sound impudent, but XviD, DivX and others like them have died, leave them for backward compatibility, but do not compress anything else with them.
For coding, I recommend MeGUI. If you read the previous parts, then you probably downloaded it for yourself. Describe how to work in it, I think, it makes no sense. If you wish, it’s easy to find manuals in Russian, but even without manuals everything is clear. They indicated the input file, indicated the output, selected the encoding profile, which are complete in the kit and clicked on the button.
Another thing if you wanted to fine-tune the settings. In general, I wanted to make a separate article on them, but in the comments I posted a link where someone very well describes all the parameters of H.264. Use it. Part 1 . Part 2 . Part 3 . Part 4 . Part 5 .
Container
Three types of containers are now popular: AVI, MKV, and MP4. If the first one, I hope, will die soon, then the last two have shown themselves very well.
To compact content in MP4, the MP4Box program is used , which has a good frontend Yamb . How to use Yamb is even a shame to describe, everything is clear there, and even if the buttons were not signed. :)
For MKV, mkvtoolnix is used . I was not going to write how to use it either, but in the previous part I promised to show how to use the time stamps that TIVTC generates. Yes, and a picture is needed, but I have recently been posting something without pictures.
Where there is a red arrow, you need to specify the path to the file that TIVTC will generate.

And also, matryoshka has one cool trick. Suppose you have anamorphic video. This is one that is stored on DVD in resolution, for example, 720x480, but when output is stretched by the player to a 16: 9 ratio. Those who code, often, due to lack of knowledge, apply filters to change the frame size. But it is not necessary.
It is best to encode the video in the resolution in which it is stored on the DVD, and then, in the matryoshka properties, when assembling the resulting video file, specify the required ratio or resolution.
Good players that support MKV will automatically stretch the video. Moreover, if the player is really good, then in the settings you can choose the algorithm by which resize will be performed.
This is much better than tweaking the video at the encoding stage.
This is done like this.

That’s probably all. See you soon! (:
The text contains edits from mvgolubev