Hi there.

I'm one of those people who think that the DVD menu is part of the movie experience - otherwise I'd just convert the VOB files and be done with it.

Yeah, I know - the DVD standard mandates mpeg-1 or mpeg-2, but in a recent test, xbmc 3:11.0-0.1 appeared to want to at least try to decode the DVD iso I converted:

You'll need to install xbmc-skin-confluence - xmbc will bail without it.

Here's a snippet from ~/.xbmc/temp/xbmc.log

CDVDVideoCodecFFmpeg::Open() Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10

So it looks promising.

I'm either encoding those VOB files incorrectly and/or not generating the ISO correctly.

I've attached a script that uses fuseiso9660 to user-mount a dvd iso onto a directory, converts the VOB files to h264 and runs genisoimage to create a new iso.

The new iso is 1,861,853,184 bytes long compared to 7,249,934,336 bytes - quite some space saving if I'm doing it right.

I've attached a script based on what information I could find - but is this approach correct?
Any comments/suggestions welcome.

Regards,
Philip Ashmore
#!/bin/sh
# Work files are created in the current directory as temp files will
# most likely be too large for /tmp.
#
# Make sure you have enough free disk space for about 3x-4x the dvd size.
#
set -e

cleanup()
{
        rm -fr $wrkdir
        rm -fr $isodir
        return $1
}
if test "$1" = "" || test ! -f $1 ; then
        echo "Usage: dvd2h264 <file.iso> [stage]"
        exit 1
fi

if "`ffmpeg -formats | grep "raw H.264 video format" | wc -l`" != "1" ; then
        echo "ffmpeg doesn't support h264!"
        exit 1
fi

wrkdir=$PWD/temp
isodir=$PWD/$1.dir

if test "$2" = "" ; then
        if test ! -d $wrkdir; then mkdir $wrkdir; else rm -fr $wrkdir/*; fi
        if test ! -d $isodir; then mkdir $isodir; else rm -fr $isodir/*; fi
        fuseiso9660 $1 $isodir

        # Has the DVD been converted already?
        avob="`ls $isodir/VIDEO_TS/*.VOB* | head -n 1 2>/dev/null`"
        if test "$avob" = "" ; then
                echo "No VOB files found in VIDEO_TS/ - not a video DVD."
                fusermount -u $isodir
                return cleanup 1
        fi
        codec="`ffprobe -show_streams VTS_01_0.VOB 2>/dev/null | head -n 10 | 
grep codec_name`"
        if test "codec" != "codec_name=mpeg2video" ; then
                echo "DVD already converted."
                fusermount -u $isodir
                return cleanup 0
        fi

        # Copy the contents into workdir
        cp -r $isodir/* $wrkdir/
        
        fusermount -u $isodir
fi

# Get rid of ;1 that fuse sometimes adds (?)
# VIDEO_TS/VTS_01_0.VOB;1
cd $wrkdir/VIDEO_TS
chmod +w .
for a in `ls *` ; do
        b="${a%*;*}"
        if test "$a" != "$b"; then
                echo "$a -> $b"
                chmod +w $a
                mv $a $b
                chmod -w $b
        fi
done

# Use ffmpeg to transform those VOB files.
for a in `ls *.VOB` ; do
        if test -f $a.h264 ; then continue; fi
        # Taken from "man ffmpeg".
        ffmpeg -i $a -map 0 -c:v libx264 -c:a copy -c:s copy $a.h264
done
echo "ffmpeg done. Replacing VOBs."
for a in `ls *.VOB` ; do
        mv -f $a.h264 $a
done
cd ../..
# All done; convert the temp dir back into a DVD.
echo "Writing DVD image result-$1."
genisoimage -o result-$1 $wrkdir
chmod --reference=$1 result-$1
# Compare them, try the new one out, etc.
# mv -f result-$1 $1

Reply via email to