[Ffmpeg-devel] Theora encoding in FFmpeg

Paul Richards paul.richards
Sat Dec 30 18:53:27 CET 2006

(Cross posted to theora-dev at xiph.org and ffmpeg-devel at mplayerhq.hu)

I am working towards adding Theora encoding support to libavcodec in
FFmpeg.  I am doing this by simply calling libtheora from libavcodec.

I am at the point where I can execute:
"./ffmpeg -v 100 -i test.wmv -f avi -an -vcodec theora -b 1000000 -y test.avi"
I get some whirring and an output file written.  My calls to libtheora
are succeeding, and I am copying the ogg_packet structures returned by
libtheora back to ffmpeg..  :)

When I attempt to decode my file with this command:
"./ffmpeg -v 100 -i test.avi -f avi -an -vcodec mjpeg -b 10000000 -y test2.avi"

I get output like so:

Input #0, avi, from 'test.avi':
  Duration: 00:00:07.4, start: 0.000000, bitrate: 694 kb/s
  Stream #0.0, 1/15: Video: theora, yuv420p, 320x240, 1/15, 15.00 fps(r)
Output #0, avi, to 'test2.avi':
  Stream #0.0, 1/90000: Video: mjpeg, yuvj420p, 320x240, 1/15, q=2-31,
10000 kb/s, 15.00 fps(c)
Stream mapping:
  Stream #0.0 -> #0.0
[theora @ 0x3c9554]Invalid extradata!
[theora @ 0x3c9554]Unknown Theora config packet: 50
[theora @ 0x3c9554]4376 bits left in packet 32
Press [q] to stop encoding
1656240 dezicycles in init_frame, 1 runs, 0 skips
1537800 dezicycles in unpack_superblocks, 1 runs, 0 skips

FFmpeg exits cleanly but test2.avi has nonsense.  Clearly the VP3
decoder (which ffmpeg uses for theora decoding) does not understand my
stream.  I am not sure if the problem is just my extradata, or if my
entire stream is borked.

To describe my ogg_packet conversion..  I first copied the code used
in oggvorbis.c which calls to av_xiphlacing etc to concatenate the
header ogg_packet structs to the extradata field.  This gives the
error above.  Next I tried concatenating just the raw contents of the
ogg_packet structs, and not performing any *xiph*() things.  This
failed just as miserably:

[theora @ 0x3c9554]Unknown Theora config packet: 50
[theora @ 0x3c9554]188016 bits left in packet B2
Press [q] to stop encoding
1636920 dezicycles in init_frame, 1 runs, 0 skips
1518600 dezicycles in unpack_superblocks, 1 runs, 0 skips

Can anyone help me with this problem?  I am happy to post source code
(currently < 200 lines), or my entire svn diff.  I am not sure if this
would be welcome on these mailing lists.

Paul Richards

More information about the ffmpeg-devel mailing list