How to backup/rip DVDs using only libre tools (and convert them to freedom respecting formats)

Last edited: 2025-05-12

For the impatient: jump to the #Guide.

Tools used

After looking at all the tools available, I have chosen to write my own script for backing up the dvds: dvd2mkv. Let's see why other tools were unsatisfactory.

Once we have obtained a nice mkv, we may use mkvpropedit from mkvtoolnix to rectify the naming and tagging of audio and subtitle tracks. For instance, you may want to set the the forced tag of a foreign language subtitle track so that in the movie, when the characters speak in the foreign language the subtitles are always activated. mkvpropedit lets you set the language of an audio track, tag an audio track as commentary ect...

When I do transcode, I prefer to use ffmpeg over handbrake but use the one that works best for you. In my opinion, ffmpeg gives you more control and is easier to understand than handbrake, because it uses less abstraction, which may scare people but is good for understanding (read ffmpeg's manual! it's very nice). ffmpeg is a ubiquitous tool and as such has high quality documentation and a million answered questions - if you encounter a problem someone will already have solved it. ffmpeg is installed pretty much everywhere and relatively recent versions are in every every repo (not the case with handbrake on parabola for instance).

File formats

See Freedom respecting file formats to use for video - Container for the reasons for which we choose mkv as the container format. When not transcoding, we by definition keep the original audio, video and subtitle codecs.

When transcoding, we use mkv container with AV1 video, Opus audio and WebVTT subtitles for text subtitles, and fallback to VOBSUB if existing subtitles were in an image format. See Freedom respecting file formats to use for video for the full breakdown.

Guide

Initial setup

Install dvd2mkv, following the instructions in the README.

On the commandline, naviguate to the directory where you will be putting your dvd rips.

Make a directory:
mkdir remuxed # we put the remuxed dvds here

Identify your optical drive:
lsblk
# the optical drive is usually /dev/sr0, /dev/dvd[0-9]

Ripping

Mount your optical drive to /media for example:
sudo mount /dev/sr0 /media

Find out the identifier of your movie on TheMovieDataBase (TMDB). Sometimes, it is hard to find the reference of the dvd, for instance, there are many different versions of Cinderella, so you should look at the copyright year written on the dvd to help you, or you can also search by actor/director on TheMovieDataBase and identify the correct movie that way.
For the naming, we make a difference between a few types of dvds. This lets us automate a tedious task latter on, bear with me and you'll be glad.
Most movies are contained in a single dvd which might come with some optional extras. For these movies, we just use the TMDB identifier. example: "White Fang (1991)"
For some movies, we have a dvd with the main movie and a dvd with extras, like the making of for instance. In this case we give the TMDB identifier to the main movie: "Star Wars: Episode II - Attack of the Clones (2002)" and we name the extra disc like so: <TMDB ID>_EXTRAS_<NAME OF EXTRA DVD>. For example: "Star Wars: Episode II - Attack of the Clones (2002)_EXTRAS_From Puppets to Pixels: Digital Characters in 'Episode II' (2002)". If the extra doesn't have a name just put "Making of" or "Bonus" or something.
Some very long movies are split accross more than one dvd. For these, we use the TMDB identifier and add _DISC<N>_ eg: "The Lord of the Rings: The Return of the King (2003)_DISC1_", "The Lord of the Rings: The Return of the King (2003)_DISC2_". In our automated future step, the main feature of disc 1 and 2 will be merged into one movie. If this movie also has extras there is no difference, the extras are named like so: "The Lord of the Rings: The Return of the King (2003)_EXTRAS_Appendicies, Fifth Part: The War of the Ring", "The Lord of the Rings: The Return of the King (2003)_EXTRAS_Appendicies, Sixth Part: The Passing of an Age".
Some dvds contain multiple movies. For these we use the TMDB identifier and add _MULTIMOVIE_ at the end: "TINTIN1_MULTIMOVIE". Unfortunately these will be have to be delt with manually.

Rip your dvd with dvd2mkv:
dvd2mkv -i /media -o remuxed --name="<NAME>" --min-size=204800
Where <NAME> is the name you found in the step above. If you don't set this name, the name will be set to the title found on the dvd (or the dvd id if the title cannot be found), which can be rather random.
This command will rip every unique title on the dvd, that is it will keep all the extra features on a dvd like making offs, trailers, bonuses ect... If you only care about the main film (the "main feature"), add the -F option.
You might want to adjust the --min-size and --min-duration options to get rid blank titles and other unwanted titles (see dvd2mkv documentation).



Note: if you have previously made an identical backup of a dvd with for example dvdbackup, you can use dvd2mkv on the backup. Say we have put all of our backups in the mirrors/ dir:
for movie in mirrors/*; do dvd2mkv -i "$movie" -o remuxed --name="$(basename "$movie")" --min-size=204800; done

Getting notified when the backup is done

One way of getting notified is by opening the optical disk tray when the backup is done. Setup your sudo privileges so you can run sudo eject without typing a password (we need sudo privileges when doing eject because it unmounts the optical drive). Then use this command to do the ripping:
dvd2mkv -i /media -o remuxed --name="<NAME>" --min-size=204800 && sudo eject

Some terminals such as urxvt let you run a custom command when receiving a bell. So if you use urxvt another way of getting notified is to set
URxvt.bell-command: notify-send "rxvt-unicode: bell!"
in your ~/.Xresources and then chain the dvd2mkv command with printf "\a"
This is useful if you are making your backups on a computer in another room in which you have sshed.

Great! now we can repeat the steps above and rip all our dvd into the remuxed/ directory.

Getting a coherent structure

create a movies/ dir
mkdir movies

Now we can merge all the _EXTRAS_ discs and the multidisc (_DISC1_, _DISC2_) movies into a more coherent structure. I wrote this script which follows the kodi naming scheme, kodi_restructure, but feel free to change it according to your needs.
kodi_restructure INPUTDIR OUTPUTDIR
where INPUTDIR is in our case "remuxed" and OUTPUTDIR is in our case "movies".
You'll notice that this script ignores the multimovie dvds. For these, you have to watch the different titles and identify them. For instance, I had this Tintin dvd which contained both "Tintin in America (1992)" and "Cigars of the Pharaoh (1991)". After ripping, the directory looked like this: remuxed/Tintin1
---- title1.mkv
---- title2.mkv
I had to skim the titles to know which corresponded to which movie and then I renamed each title accordingly. mkdir "movies/Cigars of the Pharaoh (1991)" "movies/Tintin in America (1992)"
mv remuxed/Tintin1/title1.mkv "movies/Cigars of the Pharaoh (1991)/Cigars of the Pharaoh (1991).mkv"
mv remuxed/Tintin1/title2.mkv "movies/Tintin in America (1992)/Tintin in America (1992).mkv"
rmdir remuxed/Tintin1
Important note: in the case of a long movie split accross multiple discs, my kodi_restructure script only works if the discs have their tracks numbered the same way. Let me give you an example. Let's say your movie is The Lord of the Rings, which has 2 discs. Normally, both discs will have the same number of video tracks and audio tracks, and if we have the following audio tracks for disc 1: audio track 1: english audio track 2: french audio track 3: spanish audio track 4: german then we should have the same numbering for disc 2 If this is not the case, when we merge our discs together using the default mapping, then at the middle of your movie the language will change. So, if your discs don't have the same track numbering you have to use mkvmerge manually specifying the mapping with the --append-to option.

Now we are pretty much done. You can optionally go through your mkv files and use mkvpropedit from mkvtoolnix to rectify the naming and tagging of audio and subtitle tracks. For instance, you may want to set the the forced tag of a foreign language subtitle track so that in the movie, when the characters speak in the foreign language the subtitles are always activated. mkvpropedit lets you set the language of an audio track, tag an audio track as commentary ect...

You can also transcode your movies with ffmpeg if you wish:
for mkv_file in movies/**/*.mkv; do SOME_FFMPEG_COMMAND "$mkv_file"; done

Hope this guide was helpful! Feel free to contact me if you have some improvements to suggest or questions, see contact info on dvd2mkv repo.