DVD Backup
Jellyfin
pip install jellyfin-mpv-shim python-mpv Pillow pystray
TV File Structure
# Preferred Structure / Format # Shows # ├── Series Name A (2010) # │ ├── Season 00 # │ │ ├── Some Special.mkv # │ │ ├── Series Name A S00E01.mkv # │ │ └── Series Name A S00E02.mkv # │ ├── Season 01 # │ │ ├── Series Name A S01E01-E02.mkv # │ │ ├── Series Name A S01E03.mkv # │ │ └── Series Name A S01E04.mkv # │ └── Season 02 # │ ├── Series Name A S02E01.mkv # │ ├── Series Name A S02E02.mkv # │ ├── Series Name A S02E03 Part 1.mkv # │ └── Series Name A S02E03 Part 2.mkv
DVD Handling
TL;DR (updated 2025-07-15):
Rip from DVD
sudo timedatectl set-ntp false sudo timedatectl set-time "2025-07-01" makemkvcon mkv --minlength=3600 disc:0 all mkv_out_01/ sudo timedatectl set-ntp true export DIR=the_notebook && mkdir $DIR && makemkvcon mkv --minlength=2400 disc:0 all $DIR/
Set Crop
export FILE=mkv_out_01/foo.mkv
(ffmpeg -i "$FILE" -vf cropdetect -f null - 2>&1 & echo $! > /tmp/cropdetect.id) | grep crop | head -30000 | awk '{print $14}' | sort | uniq -c | sort -n | tail -3 && pkill -P $(cat /tmp/cropdetect.id)
export CROP=crop=720:200:90:60
One Shot
ffmpeg -i "$FILE" -map 0 -vf "yadif=1:-1:0,$CROP" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy 'Clerks 3 (2022).mkv'
Compress
Cartoons with Interlacing:
export VPATH=Family_Guy-S05D01 ; ls $VPATH | perl -e '$a=0;while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export FILE=".$_." && ffmpeg -i \"\$VPATH/\$FILE\" -map 0 -vf \"yadif=1:-1:0,\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy Family_Guy-S05E$b.mkv\n";}' | sh
Latest (2025-07-29, used for live action, but should work for animation also)
export LAST_NUM=7; export DISC="03"; export SEASON="04"; export SHOW="Le_Bureau" ; export VPATH="s"$SEASON"d"$DISC; ls $VPATH | perl -e '$a='$LAST_NUM';while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"ffmpeg -i \"'$VPATH'/".$_."\" -map 0 -vf \"yadif=1:-1:0,'$CROP'\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy '$SHOW'-S'$SEASON'E$b.mkv\n";}' >> cmd-$SEASON.sh && cat cmd-$SEASON.sh
Make ISO Image
$ time dd if=/dev/sr0 of=/media/bob/backup/media/tmp/How_to_Train_Your_Dragon.iso bs=4M status=progress
Copy to Disk
makemkvcon mkv --minlength=3600 disc:0 all mkv_out_01/ makemkvcon mkv --minlength=3600 iso:How_to_Train_Your_Dragon.iso all dragon_out/
Downscale MKV With Subtitles and Audio
export FILE=mkv_out_01/foo.mkv
(ffmpeg -i "$FILE" -vf cropdetect -f null - 2>&1 & echo $! > /tmp/cropdetect.id) | grep crop | head -30000 | awk '{print $14}' | sort | uniq -c | sort -n && pkill -P $(cat /tmp/cropdetect.id)
export CROP=crop=720:200:90:60
ffmpeg -i "$FILE" -map 0 -vf "$CROP" -c:v libx264 -crf 23 -preset fast -b:a 196k -c:s copy Magnificent_Seven-The.mkv
ffmpeg -i "$FILE" -map 0 -vf "yadif=1:-1:0,$CROP" -c:v libx264 -crf 23 -preset fast -b:a 196k -c:s copy Magnificent_Seven-The.mkv
To use AAC if Vorbis is barfing:
ffmpeg -i "$FILE" -map 0 -vf "$CROP" -c:v libx264 -c:a aac -crf 23 -preset fast -b:a 196k -c:s copy Magnificent_Seven-The.mkv
ffmpeg -i "$FILE" -map 0 -vf "scale=-1:720" -c:v libx264 -crf 23 -preset fast -b:a 196k -c:s copy "../$FILE"
(ffmpeg -i "$FILE" -vf cropdetect -f null - 2>&1 & echo $! > /tmp/cropdetect.id) | grep crop | head -10000 | tail -5000 | shuf | head -10 && pkill -P $(cat /tmp/cropdetect.id) ffmpeg -i "$FILE" -vf cropdetect -f null - 2>&1 | grep crop | head -10000 | tail -5000 | shuf | head -10
crf 23 is mid-field
crf 28 is aggressive compression
ffmpeg -i "$FILE" -map 0 -vf "scale=-1:720" -c:v libx264 -crf 23 -preset fast -b:a 128k -c:s copy Firefly-s01e01-Serenity.mkv
ffmpeg -i mkv_out_01/Zombieland_t00.mkv -map 0 -vf scale=-1:720 -c:v libx264 -crf 23 -preset fast -b:a 128k -c:s copy Zombieland.mkv
720:368:0:54
ffmpeg -i input.mp4 -vf "crop=720:368:0:54" -c:v libx264 -crf 23 -preset fast output.mp4
ffmpeg -i mkv_out_01/Zombieland-J1_t00.mkv -map 0 -vf "crop=720:352:0:66" -c:v libx264 -crf 23 -preset fast -b:a 128k -c:s copy Zombieland.mkv
Fix aspect ratio without changing pixels:
ffmpeg -i input.mp4 -c copy -aspect 16:9 output.mp4
All Episodes
export CROP=crop=720:480:0:0
export VPATH=monk-s06d01 ; ls $VPATH | perl -e '$a=0;while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export VPATH=\"'$VPATH'\" && export FILE=".$_." && ffmpeg -i \"\$VPATH/\$FILE\" -map 0 -vf \"yadif=1:-1:0,\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy Monk-S06E$b.mkv\n";}' > cmd.sh
export VPATH=mkv_out_02 ; ls $VPATH | perl -e '$a=8;while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export FILE=".$_." && ffmpeg -i \"\$VPATH/\$FILE\" -map 0 -vf \"\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy Scrubs-S01E$b.mkv\n";}'
ls mkv_out_01/ | perl -e '$a=0;while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export FILE=".$_." && ffmpeg -i \"mkv_out_01/\$FILE\" -map 0 -vf \"\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy Scrubs-S01E$b.mkv\n";}'
Interlacing in Cartoons
Detect Interlacing:
ffmpeg -i input.mp4 -vf idet -frames:v 100 -an -f rawvideo -y /dev/null
remove interlacing artifacts with:
export VPATH=Family_Guy-S05D01 ; ls $VPATH | perl -e '$a=0;while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export FILE=".$_." && ffmpeg -i \"\$VPATH/\$FILE\" -map 0 -vf \"yadif=1:-1:0,\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy Family_Guy-S05E$b.mkv\n";}' | sh
-vf "yadif=0:-1:0" -c:v libx264 -flags +ilme+ildct -crf 23 -vf "yadif=0:-1:0" -flags -ilme -flags -ildct -c:v libx264 -crf 23 -vf yadif yadif=0:-1:0 (default) yadif=1:-1:0 (double frame)
list tv show seasons
video/tv/incoming$ find . -type f -name '*.mkv' | perl -e 'while(<>){chomp;if ($_=~/\/.*\/.*\//){}else{$a=$_;$a=~s/(-[SV][0-9][0-9]).*/$1/;print $a."\n";}}' | sort | uniq | cut -d '/' -f 3
Resetting a USB DVD Drive in Linux
If your USB DVD drive becomes unresponsive in Linux, you can attempt to reset it without rebooting your system by following these steps:
Identify the USB Device
Use the lsusb command to list all USB devices and find your DVD drive:
lsusb
Bus 002 Device 005: ID 152d:0562 JMicron Technology Corp. / JMicron USA Technology Corp. JMS567 SATA 6Gb/s bridge
Check the Device Status
Use dmesg or look at /var/log/syslog or /var/log/messages for any specific issues.
USB Device Reset
Reset the USB device by echoing a special value to the /sys directory:
echo 0 | sudo tee /sys/bus/usb/devices/usb[Bus]/[Bus]-[Device]/authorized echo 1 | sudo tee /sys/bus/usb/devices/usb[Bus]/[Bus]-[Device]/authorized
Replace [Bus] and [Device] with the appropriate numbers from the lsusb output.
Unloading and Reloading the Kernel Module
If you know the kernel module for your USB drive, unload it:
sudo rmmod uhci_hcd
And reload it:
sudo modprobe uhci_hcd
Restarting the udev Service
Restart the udev service, which manages device nodes:
sudo service udev restart
Using usbreset
Compile and use the usbreset program for a more convenient reset.
Note: Replace uhci_hcd with the module specific to your system. Always ensure no process is using the device before attempting a reset.
Caution: Resetting kernel modules and USB devices can lead to an unstable system state. Use these commands carefully and ensure you're not affecting other essential USB devices.
If these methods do not resolve the issue, the problem may lie with the hardware of the drive, USB port, or cable. Consider trying a different port or cable.