Last active
May 26, 2024 13:57
-
-
Save dmytro/81983fb85422a6293aaa to your computer and use it in GitHub Desktop.
Rip and encode DVD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# (c) Dmytro Kovalov, 2016. | |
# | |
# Converts VIDEO_TS folder of the DVD stored on disk into VOB file for each of the titles | |
# and converts them to H264 (using separate to264 script.) | |
# Tested on Debian Linux with: | |
# lsdvd -V | |
# lsdvd 0.16 - GPL Copyright (c) 2002, 2003, 2004, 2005 "Written" by Chris Phillips <acid_kewpie@users.sf.net> | |
# mplayer -V | |
# MPlayer svn r34540 (Debian), built with gcc-4.7 (C) 2000-2012 MPlayer Team | |
PATH=/bin:/usr/bin:/export/Movie | |
DEST_DIR=/export/Movie | |
[ -z "$1" ] && { echo "Directory?"; exit 1 ; } | |
SOURCE_DIR=$(cd "$1"; pwd) | |
dvd_content_dir() { | |
find "$SOURCE_DIR" -type d -name VIDEO_TS | |
} | |
dvd_prefix() { | |
basename "${SOURCE_DIR}" | tr '_' ' ' | |
} | |
titles() { | |
lsdvd "$(dvd_content_dir)" 2> /dev/null | awk '$1 ~ /Title/ {gsub(/[^0-9]/,"",$2); print $2}' | |
} | |
decode_title() { | |
local number=$1 | |
local prefix=$(dvd_prefix) | |
local out="${DEST_DIR}/${prefix} (${number}).vob" | |
mplayer -aid 160 -dumpfile "${out}" -dumpstream dvd://${number} -dvd-device "$(dvd_content_dir)" | |
to264 "${out}" | |
} | |
main() { | |
local title | |
for title in $(titles); do | |
decode_title $title | |
done | |
} | |
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# (c) Dmytro Kovalov, 2016. | |
# Convert any video file into H264, AAC, MP4 - directly playable on AppleTV - file. | |
# | |
# Script relies on Docker image for ffmpeg to do the conversion. Should work on any system | |
# that is able to run Docker. | |
IN=$* | |
MOVIES="/export/Movie/" | |
[ -z "$1" ] && { echo "Name?" ; exit 1; } | |
OUT=$(echo "${IN}" | grep -Po '.*(?=\.)') | |
OUT=$(basename "${OUT}") | |
DIR=$(dirname "${IN}") | |
RELATIVE_SOURCE=$(echo "${IN}" | sed "s;${MOVIES};;") | |
TARGET_DIR="Converted" | |
OPTIONS="-crf 23 -vcodec libx264 -acodec libfaac -ar 48000 -ab 192k -ac 2 -async 48000 -r 30" | |
docker run -d -v ${MOVIES}:/v jrottenberg/ffmpeg -i "/v/${RELATIVE_SOURCE}" ${OPTIONS} "/v/${TARGET_DIR}/${OUT}.mp4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment