Video file conversions
Re-encoding to H.264/AAC
(2018-08-10)
After discovering and downloading TV series Fireball XL5, Space: 1999 and UFO from http://archive.org I was surprised to see that these episodes had very good quality video, buy small file sizes. Turns out they are encoded with H.264 and AAC encapsulated in MP4 files. The 50-minute episodes were less than 200MB each, yet were visually perfect during playback. Compare this file size with a ripped DVD VOB at approximately 1800MB for a 50-minute segment. This is about a 9:1 ratio, and I'm stunned. I have 20TB of storage on my media storage server, and running low, and I'm starting to believe that a re-encoding of at least the ripped DVD videos could release a lot of storage space.
Most of my DVD rips (VOBs) and Over-The-Air (MTS) files contain MPEG2 video with MPEG2 audio streams. To convert these, or anything else for that matter, to MP4 (H.264 with AAC) files with PuppyLinux 5.2.8 or 5.7.1 use:
ffpmeg -y -i <INFILE> \ -vcodec libx264 -preset medium -vf scale=640:480 -aspect 4:3 \ -acodec libvo_aacenc -ab 192k \ <OUTFILE>.mp4
Some files, particularly OTA files, are of old 4:3 shows, but are broadcase in 16:9 frames with black boarders. Since we are re-encoding anyway, we might as well crop and rescale, as needed, using:
- For 720x480 with aspect 16:9 use:
ffpmeg -y -i <INFILE> \ -vcodec libx264 -preset medium -vf crop-540:480:90:0,scale=640:480 -aspect 4:3 \ -acodec libvo_aacenc -ab 192k \ <OUTFILE>.mp4
- OR, for 704x480 with aspect 16:9 use:
ffpmeg -y -i <INFILE> \ -vcodec libx264 -preset medium -vf crop-528:480:88:0,scale=640:480 -aspect 4:3 \ -acodec libvo_aacenc -ab 192k \ <OUTFILE>.mp4
2018-11-24
Notes on converting VIDEO collection to MP4 (H.264/AAC) format
Background
In the past two days I have been experimenting with various VOB, MPG, and MTS file converstion to MP4. I have discovered that though the encoding is a relatively slow process, the resulting file size is from 20% to 30% *less* than the original file. And, it seems that the visual quality is just as high as the original, too.
There are several benefits to doing this:
- File size is drastically reduced:
- meaning faster file transfer
- reduces storage requirements
- possibly allows multiple copies (backups) using the storage space I already have
- Playback on Nook Books (android) and iPhone is possible, with some files even playable on Palm Pixi
Some key things to consider as a file is converted:
- Resolution: DVD VOB files are generally scaled to 720x480 (704x480) and must be scaled during the conversion process in order for the ascpect ratio to be correct when playing on simple devices, i.e., Nook books.
- Letterbox: some DVD VOB use letterboxing for video aspects greater than 16:9 such as extra wide films, and OTA MTS files use letterboxing to show a 4:3 aspect video in a 16:9 stream.
- Display Aspect Ratio (DAR): While KODI and other playback systems can adjust for embedded DAR values, most simple playback devices (nooks) cannot. Particularly after removal of letterboxing, the scaling and DAR must be correctly set.
- Multi-channel Audio: simple playback devices (nook books) can only playback files with 1- or 2-channel audio. Files with 5.1 or higher audio streams fail to playback correctly, or at all.
- Interlacing: the video should be de-interlaced for best playback on various devices, and seems to have no ill effect when played back on CRT TV via KODI.
Processing method
- Test for letterboxing: use
ffmpeg
with-vf cropdetect
to determine the true image dimensions. - Determine scaling: convert the stored image dimensions to actual display dimensions for the crop and scaling operation to come.
- Discover audio: use
ffprobe
to discover how many audio streams are included, and which are 1- or 2-channel, and more.