سؤال

FLV format specification is here: http://www.adobe.com/content/dam/Adobe/en/devnet/flv/pdfs/video_file_format_spec_v10.pdf

1) FLV body consists of tags

2) Each tag consists of header and data

3) Data may be AUDIODATA or VIDEODATA

4) AUDIODATA consists of descriptor byte and audio frames.

My question is: what is in IPacket when reading FLV with Xuggler?

Currently I do extract audio frames from AUDIODATA in my code. I analyze first byte, deduce format, cut other data, wrap it into IPacket and send it to IStreamCoder decoder, which was set up with deduced format.

But may be I can entrust this to Xuggler? May be I can create IContainer of FLV format and peek packets from it?

Suppose I pass InputStream to IContainer. Can this stream contain just FLV body? Will it extract audio packets correctly?

هل كانت مفيدة؟

المحلول

The IContainer object in Xuggler will parse the FLV stream and use it to determine the IStream's in the container. Then as you read each packet from the IContainer, check the IPacket#getStreamIndex() value. This gives you the stream #, which you can then use on the IContainer to get the IStream object with the meta-data.

The IPacket#getData() method will return the payload of the audio, but not any of the header bytes. That is because the IContainer/IStream object eats those bytes (and they are not accessible independently through Xuggler).

All of this works because IContainer delegates to FFmpeg's libavformat C-code which does the job of parsing FLV streams (used by VLC, mPlayer, and all sorts of other libraries).

Hope that helps,

Art

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top