UP  |  HOME

Video Archival

Table of Contents

I keep a copy of each DVD image or a decrypted backup of Blu-rays. This makes re-ripping easy, and might let me ignore discs rotting and such.

Workflow

video_archival_workflow.svg

Idealized workflow (future hbr additions)

In this workflow the mythical hbr gui does some semi-automated matching like musicbrainz picard does. The big difference is there is no central database for DVD/BD chapter info like there is for music releases. So instead we'll rely on the user pasting a blob of text with like "Title hh:mm:ss" or something and try to match chapters with their titles.

Ideally I'd like to depend directly on libhb, but it's not built as a standalone library. Alternatively keep relying on parsing HandBrakeCLI --scan and maintain the current hbr file format with some concessions made towards primarily using HandBrake's Video Profiles for encoder settings.

video_archival_ideal_workflow.svg

DVD

Play first with VLC to handle CSS encryption. Then exit and use ddrescue to make a copy of the disc:

vlc /dev/sr0
ddrescue /dev/sr0 /path/to/movie.iso

This doesn't decrypt, but VLC and Handbrake can do it themselves via libdvd / libdvdcss.

Blu-ray

MakeMKV's backup works great for copying Blu-ray contents and decrypting the AACS keys. Files are stored in video/iso/<movie title>/<Blu-ray Label>. The process is GUI driven and straightforward. Just make sure the decrypt option is checked when you start a backup.

When it comes to matching content names with titles on blu-ray you need a decent player. VLC has some support, but it's practically useless. There are a couple free windows players that do the job with some hiccups. Try DVDFab Player 5 or Leawo Blu-ray Player. DVDFab is preferable for it's ability to access to chapter numbers and such. I ran into some incompatibilies with certain studio's blu-ray menus. Sometimes you just have to do a lot of guess and check using the playlist files and context clues to properly match content.

Encoding with hbr and HandBrake

Creating hbr files:

hbscan.py

I created hbscan to parse HandBrakeCLI –scan output and create hbr outfile sections for each title. It is best suited for non-episodic releases (mostly movies) because it doesn't insert episode/season keys. It doesn't generate the initial config section. I usually copy that section from a previous hbr file. It would look something like this:

Listing 1: test.hbr
[CONFIG]
input_basedir=/mnt/video/iso/<movie name>/
output_basedir=/mnt/video/movies/<movie name>/
iso_filename=<filename>
type=movie name=<movie name>
year=<movie year>

Then you run hbscan.py on the iso or blu-ray directory and redirect output to the hbr file:

hbscan.py /path/to/movie.iso >> test.hbr

For multi-disc releases you probably want hbscan.py –-setiso to set the iso_filename for each outfile section. hbscan.py can also exclude titles under a minimum length (usually intros, piracy warnings, etc.) Check hbscan.py –help for a quick overview.

This gives you a pretty good start on the hbr file. Most of the rest of the work is:

  • Remove unwanted outfile sections
  • Adjusting subtitle and audio track ordering
  • Remove unwanted subtitle/audio tracks
  • Setting names for each title
  • Setting an extra type for non-feature content.

hbr-gen

Whereas hbscan takes the disc structure and lets you match content hbr-gen sort of does the opposite by working from a list of content that you match with disc titles. It also has simpler modes to generate a fixed number of outfile sections.

Running hbr:

hbr takes one or more hbr files as input, and runs encodes for each OUTFILE section.

Sometimes it's a good idea to verify the commands hbr will run first with the -d/--debug option:

hbr -d test.hbr

A normal run to actually encode is just:

hbr test.hbr

Other useful options are -e/--episode to specify a particular episode, -y/--overwrite to overwrite a previous encode without confirmation, and -n/--skip to only encode when a previous encode doesn't exist.

Checking files for corruption or bad encodes

Testing with ffmpeg and find

Change the file extension to suit.

find . -name "*.mkv" -exec sh -c "ffmpeg -v error -i '{}' -map 0:1 -f null - 2>'{}.log'" \;

Solution found via:

Testing with Spek (for audio, one file at a time)

Spek analyzes the audio spectrum and draws a spectrograph. It can be useful for detecting audio issues. It's a bit slow and not batchable, but the extra analysis might be useful.