]> code.delx.au - transcoding/blob - identify-disc-mpv
avconv -> ffmpeg
[transcoding] / identify-disc-mpv
1 #!/bin/bash -e
2
3 if [ -z "$1" -o -z "$2" ]; then
4 echo "Usage: $0 --bluray-device|--dvd-device SOMEDIRECTORY"
5 exit 1
6 fi
7
8 device_param="$1"
9 device_path="$2"
10 if [ "$device_param" = "--bluray-device" ]; then
11 device_scheme="bd"
12 elif [ "$device_param" = "--dvd-device" ]; then
13 device_scheme="dvd"
14 else
15 echo "Unknown device type: $device_param"
16 exit 1
17 fi
18
19 function mpv_wrap {
20 mpv 2> /dev/null \
21 --quiet \
22 --ao=null \
23 --vo=null \
24 --frames 1 \
25 --no-cache \
26 --no-config \
27 "$@"
28 }
29
30 function get_highest_title {
31 mpv_wrap \
32 "$device_param" "$device_path" "${device_scheme}://" \
33 --term-playing-msg='${disc-title-list}TITLE_LIST_END' \
34 | grep -B2 'TITLE_LIST_END' \
35 | head -n1 \
36 | cut -d':' -f1
37 }
38
39 function get_length {
40 mpv_wrap \
41 "$device_param" "$device_path" "${device_scheme}://${1}" \
42 --term-playing-msg='TITLE_LENGTH=${duration}' \
43 | grep 'TITLE_LENGTH' \
44 | head -n1 \
45 | cut -d'=' -f2
46 }
47
48 highest_title="$(get_highest_title)"
49 for title in $(seq 0 "$highest_title"); do
50 echo -n "$title "
51 get_length "$title"
52 done
53