XAvAX
31st December 2009, 11:55
I'm on Exherbo, and there's no package for subtitle2vobsub. Also, none of the versions I found online were either maintained OR compilable. Thus, I modified abdvde_encode_subtitles to make use of mplayer's -vobsubout parameter, which eliminated the need for subtitle2vobsub.
function abdvde_encode_subtitles
{
echo "abdvde_encode_subtitles" >>"$LOG"
if ! $RIP_SUBTITLES; then
return
fi
printf "Encoding subtitle streams: "
case "$CONTAINER" in
"mkv")
for INDEX in `mplayer dvd://$TITLE -dvd-device "$INPUT" -v -vo null -nosound -frames 10 2>>"$LOG" | grep "( sid )" | sed -r "s/subtitle \\( sid \\): ([0-9]).*/\\1/"`; do
local SID="$INDEX"
INDEX=`mplayer dvd://$TITLE -dvd-device "$INPUT" -v -vo null -nosound -frames 10 2>>"$LOG" | grep "subtitle ( sid ): $SID"`
local LANGUAGE=`printf "$INDEX" | sed -r "s/.*language: ([a-z]+)/\\1/"`
if [ "$LANGUAGE" = "unknown" ]; then
LANGUAGE="und"
fi
local TRACK=$(( 32 + $SID ))
printf " $LANGUAGE"
mencoder -dvd-device "$INPUT" dvd://$TITLE -oac copy -ovc copy -o /dev/null -ifo "$TMP/extracted/VTS_01_0.IFO" -sid $SID -vobsubout "$TMP/mux/subtitles.$TRACK.$LANGUAGE"
done
;;
"ogm")
for STREAM in "$TMP/extracted/subtitles"*; do
if [ "$STREAM" = "$TMP/extracted/subtitles*" ]; then
break
fi
printf "$LANGUAGE ";
local TRACK=`printf "$STREAM" | sed -r "s/.*subtitles\\.([0-9]+)\\.([a-z]+)\\.ps1/\\1/"`
local LANGUAGE=`printf "$STREAM" | sed -r "s/.*subtitles\\.[0-9]+\\.([a-z]+)\\.ps1/\\1/"`
if [ "$STREAM" = "$TMP/extracted/subtitles/*" ]; then
break
fi
cat "$STREAM" | subtitle2pgm -o "$TMP/subtitles.$TRACK.$LANGUAGE"
case "$LANGUAGE" in
"en"|"fr"|"de") pgm2txt -v -f $LANGUAGE "$TMP/subtitles.$TRACK.$LANGUAGE";;
*) pgm2txt -v "$TMP/subtitles.$TRACK.$LANGUAGE";;
esac
ispell "$TMP"/subtitles*.txt
srttool -s -w -i "$TMP/subtitles.$TRACK.$LANGUAGE.srtx" -o "$TMP/mux/subtitles.$TRACK.$LANGUAGE.srt"
done
;;
esac
printf "\n"
}
I had to pull the case outside the loop to do it, but there might be a better way. I was just hacking it to get it running. Other than that, the filestat etc. problems addressed above were the only issues I found. Thanks for a great tool!
function abdvde_encode_subtitles
{
echo "abdvde_encode_subtitles" >>"$LOG"
if ! $RIP_SUBTITLES; then
return
fi
printf "Encoding subtitle streams: "
case "$CONTAINER" in
"mkv")
for INDEX in `mplayer dvd://$TITLE -dvd-device "$INPUT" -v -vo null -nosound -frames 10 2>>"$LOG" | grep "( sid )" | sed -r "s/subtitle \\( sid \\): ([0-9]).*/\\1/"`; do
local SID="$INDEX"
INDEX=`mplayer dvd://$TITLE -dvd-device "$INPUT" -v -vo null -nosound -frames 10 2>>"$LOG" | grep "subtitle ( sid ): $SID"`
local LANGUAGE=`printf "$INDEX" | sed -r "s/.*language: ([a-z]+)/\\1/"`
if [ "$LANGUAGE" = "unknown" ]; then
LANGUAGE="und"
fi
local TRACK=$(( 32 + $SID ))
printf " $LANGUAGE"
mencoder -dvd-device "$INPUT" dvd://$TITLE -oac copy -ovc copy -o /dev/null -ifo "$TMP/extracted/VTS_01_0.IFO" -sid $SID -vobsubout "$TMP/mux/subtitles.$TRACK.$LANGUAGE"
done
;;
"ogm")
for STREAM in "$TMP/extracted/subtitles"*; do
if [ "$STREAM" = "$TMP/extracted/subtitles*" ]; then
break
fi
printf "$LANGUAGE ";
local TRACK=`printf "$STREAM" | sed -r "s/.*subtitles\\.([0-9]+)\\.([a-z]+)\\.ps1/\\1/"`
local LANGUAGE=`printf "$STREAM" | sed -r "s/.*subtitles\\.[0-9]+\\.([a-z]+)\\.ps1/\\1/"`
if [ "$STREAM" = "$TMP/extracted/subtitles/*" ]; then
break
fi
cat "$STREAM" | subtitle2pgm -o "$TMP/subtitles.$TRACK.$LANGUAGE"
case "$LANGUAGE" in
"en"|"fr"|"de") pgm2txt -v -f $LANGUAGE "$TMP/subtitles.$TRACK.$LANGUAGE";;
*) pgm2txt -v "$TMP/subtitles.$TRACK.$LANGUAGE";;
esac
ispell "$TMP"/subtitles*.txt
srttool -s -w -i "$TMP/subtitles.$TRACK.$LANGUAGE.srtx" -o "$TMP/mux/subtitles.$TRACK.$LANGUAGE.srt"
done
;;
esac
printf "\n"
}
I had to pull the case outside the loop to do it, but there might be a better way. I was just hacking it to get it running. Other than that, the filestat etc. problems addressed above were the only issues I found. Thanks for a great tool!