This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
copy_dvd [2019-07-22 11:31:39] mi created |
copy_dvd [2021-12-26 14:54:08] (current) mi |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Copying / transcoding a DVD with ffmpeg ====== | + | = Copying / transcoding a DVD with ffmpeg |
- | * First, copy the DVD to a hard drive | + | * First, copy the DVD to a hard drive |
- | ===== For unencrypted DVDs: ===== | + | == For unencrypted DVDs: |
* Use VLC to check which are the correct files. In the example below, they are VTS_01_1.VOB to VTS_01_3.VOB. | * Use VLC to check which are the correct files. In the example below, they are VTS_01_1.VOB to VTS_01_3.VOB. | ||
Line 29: | Line 29: | ||
Or to copy only the first subtitle track, use : <code>-c:v copy -c:a copy -c:s copy</code> | Or to copy only the first subtitle track, use : <code>-c:v copy -c:a copy -c:s copy</code> | ||
+ | === More options | ||
+ | vob_opt=(-probesize 1G -analyzeduration 1G -r 25 -fflags +genpts) | ||
+ | h264_opt=(-c:v libx264 -tune film -pix_fmt yuv420p -profile:v high -level 4.0 -preset fast -crf 18) | ||
+ | filter_opt=(-filter:v "yadif=0:-1:0, scale=iw*sar:ih:flags=lanczos, setsar=1") | ||
+ | col_opt=(-colorspace bt470bg -color_primaries bt470bg -color_trc gamma28) | ||
+ | keyframes_opt=(-g 25) | ||
+ | audio_opt=(-c:a aac -b:a 160k) | ||
+ | test="-t 120" # 120 seconds for testing | ||
+ | |||
+ | then | ||
+ | |||
+ | ffmpeg "${vob_opt[@]}" -i "$in" $test "${col_opt[@]}" "${h264_opt[@]}" "${keyframes_opt[@]}" "${filter_opt[@]}" "${audio_opt[@]}" "$out" | ||
+ | |||
+ | == Check if the DVD uses CSS copy protection | ||
+ | * Try playing single .VOB files in VLC. | ||
+ | * Or use ''check-dvd-css.pl'' with one of the .VOB files : | ||
+ | <file perl check-dvd-css.pl> | ||
+ | #!/usr/bin/perl | ||
+ | |||
+ | my $VERSION=0.1; | ||
+ | |||
+ | my $sector_size = 2048; | ||
+ | my $count = 1000; | ||
+ | |||
+ | use strict; | ||
+ | use autodie; | ||
+ | |||
+ | |||
+ | my $file = shift; | ||
+ | die "Not found: $file\n" unless (-f $file); | ||
+ | |||
+ | if (-s $file < $count * $sector_size) { | ||
+ | $count = int( (-s $file)/$sector_size ); | ||
+ | warn "File too small. Checking $count sectors only ($file)\n"; | ||
+ | } | ||
+ | |||
+ | my $protected = 0; | ||
+ | |||
+ | open my $fh, '<:raw', $file; | ||
+ | |||
+ | for (my $s=0; $s<$count; $s++) { | ||
+ | my $bytes_read = read($fh, my $sector, $sector_size); | ||
+ | die "Got $bytes_read but expected $sector_size from $file\n" unless ($bytes_read == $sector_size); | ||
+ | |||
+ | my @bytes = unpack("C*", $sector); | ||
+ | if ( ($bytes[ ($bytes[13] & 7)+20 ] & 48) != 0 ) { | ||
+ | $protected++; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if ($protected) { | ||
+ | print "CSS-protected (on $protected of $count sectors) : $file\n"; | ||
+ | } else { | ||
+ | print "NOT protected : $file\n"; | ||
+ | } | ||
+ | </file> | ||
+ | |||
+ | =Extract subtitles | ||
+ | |||
+ | List content with ''lsdvd -x''. From the output, select the VTS index for the movie, and select the index of the wanted subtitle track. | ||
+ | |||
+ | vtsid=2 # "Title: 02, [...] VTS: 02" will use VTS_02_0.IFO | ||
+ | subid=0 # "Subtitle: 01" : 1st subtitle track is index 0 | ||
+ | |||
+ | mencoder -dvd-device VIDEO_TS dvd://1 -nosound -ovc 'copy' -o /dev/null -ifo VIDEO_TS/VTS_0${vtid}_0.IFO -sid $subid -vobsubout vobsubs-$subid | ||
+ | |||
+ | (See also https://www.rigacci.org/wiki/doku.php/doc/appunti/linux/video/vobcopy) | ||
+ | |||
+ | {{tag>public video perl}} |