Having moved away from Rogers Cable TV to over-the-air (OTA) using a TV Antenna, I needed a way to record programs so I can watch them later.
For this, I got the MediaSonic HomeWorx HW150 PVR, which is inexpensive ($50 with price matching).
The PVR records files as ones with .mts extension, which is AVCHD (Advanced Video Coding High Definition). The average size is 6.3 GB per hour of recording. This is of course excessive, and I needed a way to make the files smaller while preserving an acceptable level of quality.
For this, I found that avconv, which is a fork of the popular ffmpeg. It is what is available on Ubuntu 14.04.1, Server version. It has support for libx264 which is crucial for good quality video conversion.
This is all done from the command line, with no desktop interaction needed. If you are not comfortable with the command line, then you may opt for something with a GUI, such as Handbrake.
To install the package you do:
sudo aptitude install libav-tools
Then, for each .mts video, I had a script that wrapped the following command into some script with logging, time and size measurement and error checking.
The basic command is:
avconv -v fatal -y -i video.mts -c:v libx264 -crf 22 -s hd720 -preset veryfast -acodec copy video.mkv
To explain the options, they are:
-c:v libx264 : use the H264 format for the output
-crf 22: Use a constant rate factor of 22.
-s hd720 : downscale from 1080 to 720.
-preset veryfast : use a preset. Trial and error shows which ones works best for your videos.
-acodec copy : Copy the input audio codec as is. In this case it is Dolby Digital 5.1 ac3.
Also, for the output, I used the Matroska container (.mks).
To measure the size of the input, I used the following command, where /mnt/disk1 is the mount point of the source USB disk:
find /mnt/disk1 -type f -name "*.mts" | awk '{s += $1} END {print s/1024}'
Similarly, to measure the size of the target files, I used the command:
find /mnt/disk2 -type f -name "*.mks" | awk '{s += $1} END {print s/1024}'
Performance
The results are that on an older AMD Athlon 64 X2 Dual Core Processor 4400+ with 2.2GHz, and 2 GB of RAM, and both the input and output on USB attached disks, the server can transcode at around 5,100 MB/Hr.
This means that the initial 650GB took several days to complete.
On a more recent laptop, an HP Pavilion with an Intel Core i5 CPU 450M running at a maximum of 2.4 GHz, 2 cores and 4 threads, the performance is much better, at 11,499 MB/Hr.
Most Comments
Most commented on articles ...