Elf wrote:
> I'm using pymedia 1.3.7.3 (latest available at sf.net).
> Using example (recode_audio.py) from pymedia.org i'll try to recode
> mp3 to ogg.
> Ogg file is produced, but noone player can't play it.
> I tried number of files and bitrates with same result.
>
> Ogg decoding works fine.
I had the same problems. There are actually to issues in pymedia:
1) the generated frames by the encoder are pushed into the muxer
and then written to the file. This somehow adds additional bytes
to the frames which corrupt the ogg stream (from recode_audio.py):
enc_frames = enc.encode( r.data )
if enc_frames:
for efr in enc_frames:
ss = mx.write(stId, efr)
if ss:
print "writing %d bytes (%d)" % (len(ss), len(efr))
fw.write(ss)
if the frames are directly written to the files, the resulting ogg file
stream is correct except at the end (see 2):
enc_frames = enc.encode( r.data )
if enc_frames:
for efr in enc_frames:
fw.write(efr)
2) the EOS marker is missing at the end of the stream. This is because
there is still encoded data in the encoder once the last inframes
have been
written to the encoder. There is currently no way in pymedia to inform
the encoder about the end of the input so that it can flush out the
remaining
encoded frames (only the write method supplies a buffer where the
encoder
can put the encoded frames into). Unfortunately the call from the
internal
encode method of pymedia to the encode method of the format's
encoder always
assumes a fixed amount of samples, so there is no way of signaling
the end of data
to the format's encoder. Oggvorbis needs this information to flush
out the
final bytes and set the EOS flag.
I've modified pymedia's avcodec.c to accept an empty string in its
ACodec_Encode(...) method an call the format's encoder with NULL
for the data so that the oggvorbis.c encoder can detect the end and
flush
out the remaining bytes.
So at the end of encoding in recode_audio.py I issue a final
enc.encode("")
and write out what I get back from the encoder and the resulting
file/stream
is correct:
enc_frames = enc.encode("")
if enc_frames:
for efr in enc_frames:
fw.write(efr)
f.close()
But before I supply a patch, I'd like to know about the Muxer issue:
Why does the muxer add additional bytes that corrupt the ogg stream?
Is it the fault of the muxer or should there be no muxer involved when
encoding
to ogg? I don't currently understand the purpose.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Pymedia-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pymedia-users