翻錄 DVD 的章節以分離文件

翻錄 DVD 的章節以分離文件

我有一張兒童卡通 DVD,每張都有幾集。我怎麼能把它們翻錄成每一集都在一個單獨的文件中?我認為每一集都被寫成 DVD 上一個標題中的一個章節。

答案1

提取標題 2 第 3 章的 .VOB

請注意,「-chapter 3」和「-chapter 3-」將從第 3 章複製到末尾,如果您指定的章節編號無效,則該選項將被忽略,因此將複製完整標題。

# physical DVD
  mplayer dvd://2 -chapter 3-3 -dumpstream -dumpfile ~/3.VOB

# DVD .iso image  
  mplayer dvd://2 -dvd-device "$dvd_iso" -chapter 3-3 -dumpstream -dumpfile ~/3.VOB  

您可以用於lsdvd列出實體 DVD 的標題、章節、儲存格、音訊、視訊等。 但是,似乎(?)沒有辦法處理.iso. 你可以掛載 .iso, 如果需要的話。

# count Titles, and count Cells per title. 
# eg. ${cell[1]}      is the Count of Cells for the first title
#     ${cell[titles]} is the Count of Cells for the last title

eval $(lsdvd | sed -n 's/Title: \([0-9]\+\), .* Chapters: \([0-9]\+\), Cells: .*/cells[$((10#\1))]=$((10#\2));/p')
titles=${#cells[@]}

title_num=2
from_cell=1
to_cell=${cell[title_num]}

dvdxchap另一方面,可以處理 a .iso,但它不列出標題資訊。 但是,您可以指定想要從中取得章節資訊的標題。

  title_num=2
  from_cell=1
# physical DVD
  to_cell="$(dvdxchap -t $title_num  /dev/dvd | sed -n 's/^CHAPTER\([0-9]\+\).*/\1/p' | sed -n '$p')"
# DVD .iso image  
  to_cell="$(dvdxchap -t $title_num "$dvd_iso"| sed -n 's/^CHAPTER\([0-9]\+\).*/\1/p' | sed -n '$p')"   

當您知道所需的標題編號並知道儲存格數量時,您可以將它們轉儲到循環中:

# physical DVD
  for ((c=$from_cell; c<$to_cell; c++)) ;do
    mplayer dvd://$title_num -chapter $c-$c -dumpstream -dumpfile ~/$c.VOB
  done

# DVD .iso image  
  for ((c=$from_cell; c<$to_cell; c++)) ;do
    mplayer dvd://$title_num -dvd-device "$dvd_iso" -chapter $c-$c -dumpstream -dumpfile ~/$c.VOB
  done

答案2

lsdvd作為使用、Python 和ffmpeg將 DVD 中的章節提取到當前目錄 ( )的腳本extract-chapters.sh

#!/bin/sh

_genpy () {
    if [ -n "$2" ]; then
        lsdvd -x -Oy -t "$2" "$1"
    else
        lsdvd -x -Oy "$1"
    fi

    # Process in Python
    cat <<EOF
for t in lsdvd['track']:
    for c in t['chapter']:
        print '{}\t{}\t{}\t{}'.format(t['vts'], t['ix'], c['ix'], c['length'])
EOF
}

_genpy "$@" 2> /dev/null | python | {
    dvd_pos=0
    while read line
    do
        dvd_file=$(printf '%02d' $(echo "$line" | cut -f1))
        dvd_tr=$(echo "$line" | cut -f2)
        dvd_cp=$(echo "$line" | cut -f3)
        dvd_len=$(echo "$line" | cut -f4)
        file_name="${dvd_tr}.${dvd_cp}.mkv"
        cat "$1/VIDEO_TS/VTS_${dvd_file}"_*.VOB | ffmpeg -ss "$dvd_pos" -i - -t "$dvd_len" -c:v libvpx -c:a libvorbis -loglevel error "$file_name"
        echo "Created $file_name"
        dvd_pos=$(echo "$dvd_pos + $dvd_len" | bc)
    done
}

用法:

sh extract-chapters.sh PATH_TO_DVD_CONTENTS [TRACK]

相關內容