Hi Keenan,
On Sat, Mar 05, 2005 at 12:10:49AM -0500, Keenan Pepper
wrote:> I tried to encode some video from a DVD with encoder_example and
> ffmpeg2theora, and it looked great, except that with both encoders the
> A/V sync would drift noticeably after about 10 minutes, and by the end
I can not tell if your guess about the cause of the problem is right or not,
but I'd appreciate if you can give a run the theora-encoder script
and see if it breaks in the same way (it shouldn't).
The script runs mplayer and as such does not make the sync a "Theora
issue", the data which theoraenc is fed with should be correct
and that's enough.
> So it seems to me the only way to keep A/V sync when transcoding from
> MPEG or any timestamp-based format into Theora is to drop frames or
> alter audio samples when the A/V offset gets too high. Neither the
> encoder_example nor ffmpeg2theora currently does this, so the sync drifts.
See above, Theora-related part should not have to be aware of that.
If it is a bug in ffmpeg2theora, then of course go ahead and fix.
Ffmpeg2theora is a bit faster than running separate mplayer processes, but it
has some limitations - like it does not accept the "too big" avi files
that xawtv tends to produce on longer TV shows.
Mplayer takes them happily and theora-encoder converts them to theora
as well.
Regards,
--
Ivan
-------------- next part --------------
#!/bin/sh
# Theora encoder -- encodes any video file playable by mplayer to Theora
# (c) 2003 Ark Linux, written by Bernhard Rosenkraenzer
<bero@xxxxxxxxxxxx>
#
# Released under the GNU GPL v2 or if, and only if, the GPL v2 is ruled
# invalid in a court of law, any subsequent version of the GPL.
#
# Minor tweaks by Ivan Popov <pin> July 2004, December 2004
#
ARGS=""
AUDIO=""
VIDEO=""
while [ "`echo $1 |cut -b1`" = "-" ]; do
case $1 in
-a|--audio-quality)
shift
ARGS="$ARGS -a $1"
;;
-A|--audio-bitrate)
shift
ARGS="$ARGS -A $1"
;;
-v|--video-quality)
shift
ARGS="$ARGS -v $1"
;;
-V|--video-bitrate)
shift
ARGS="$ARGS -V $1"
;;
-o|--output)
shift
DEST="$1"
if [ "`echo $DEST |cut -b1`" != "/" ]; then
DEST="`pwd`/$DEST"
fi
DEST="\"$DEST\""
ARGS="$ARGS -o $DEST"
;;
-aa|--audio-arg)
# Pass an argument to the audio decoder
shift
AUDIO="$AUDIO \"$1\""
;;
-va|--video-arg)
# Pass an argument to the video decoder
shift
VIDEO="$VIDEO \"$1\""
;;
-aspect)
# Aspect ratio of input file
shift
VIDEO="$VIDEO -aspect \"$1\""
;;
-s|--aspect-numerator)
# Pixel aspect ratio numerator
shift
ARGS="$ARGS -s $1"
;;
-S|--aspect-denominator)
# Pixel aspect ratio denominator
shift
ARGS="$ARGS -S $1"
;;
-f|--framerate-numerator)
# Framerate ratio numerator
shift
ARGS="$ARGS -f $1"
;;
-F|--framerate-denominator)
# Framerate ratio denominator
shift
ARGS="$ARGS -F $1"
;;
*)
echo "WARNING: Unknown option $1 ignored!" >&2
esac
shift
done
if [ -z "$1" -o "$#" != "1" ]; then
cat >&2 <<EOF
Usage: $0
[-a audioquality|-A audiobitrate]
[-v videoquality|-V videobitrate]
[-s pixel-aspect-numerator] [-S pixel-aspect-denominator]
[-f framerate-numerator] [-F framerate-denominator]
[-aa audio-decoder-arg [-aa audio-decoder-arg] ...]
[-va video-decoder-arg [-va video-decoder-arg] ...]
[-o outputfile]
inputfile
EOF
exit 1
fi
SRC="$1"
case x"$SRC" in
# for dvd://1 and alike :
*:*) ;;
*)
if [ "`echo $SRC |cut -b1`" != "/" ]; then
SRC="`pwd`/$SRC"
fi
;;
esac
SRC="\"$SRC\""
DIR=`mktemp -d /tmp/theoraXXXXXX`
cat >$DIR/run.sh <<EOF
trap "rm -rf $DIR" 0 1 2 3 4 6 8 9 11 13 15
cd $DIR
mkfifo -m 0600 stream.yuv stream.wav
mplayer -ao pcm -aofile stream.wav -vo null -vc null $AUDIO $SRC
&>mplayer-audio.log &
mplayer -vo yuv4mpeg -ao null -nosound $VIDEO $SRC &>mplayer-video.log
&
theoraenc $ARGS stream.wav stream.yuv
rm -rf $DIR
EOF
chmod +x $DIR/run.sh
exec $DIR/run.sh