On 9/15/2011 1:58 PM, Michael Chisholm wrote:
I am using ffmpeg 0.6.3; I can upgrade if necessary.
My problem is that the FLV muxer, as far as I can tell, is putting an
empty decoder config record into the stream. I tried just transcoding a
file using the ffmpeg commandline tool:
ffmpeg -i ../../test/somefile.mpg -vcodec libx264 -f flv -fpre
../share/ffmpeg/libx264-default.ffpreset ../../somefile_h264.flv
and I have my own little file analyzer I wrote that dumps info about flv
files. It shows the following for the first few tags:
Tag type: script
dataSize for this tag = 159
timestamp = 0
Tag type: video
dataSize for this tag = 5
timestamp = 0
Frame type: keyframe
CodecID: AVC
AVC packet details:
Packet type: AVC sequence header
Sequence header hex dump (0 bytes):
Tag type: video
dataSize for this tag = 1839
timestamp = 0
Frame type: keyframe
CodecID: AVC
AVC packet details:
Packet type: AVC NAL unit
Composition time offset: 33
Tag type: video
dataSize for this tag = 2625
timestamp = 33
Frame type: inter frame
CodecID: AVC
AVC packet details:
Packet type: AVC NAL unit
Composition time offset: 33
etc...
Notice that the "AVC sequence header" packet in the second tag has no
data. This also happens with the actual tool I'm building, which uses
libav* programmatically to transcode video to flash that can be played
in a flash plugin in a web browser. I've never seen anything play in
the plugin, and I've read that the plugin requires this decoder
configuration record in order to work.
So my question is: does libav* support complete creation of this decoder
config record? Or is it written to always output an empty one?
Well I've partially figured this out. Libav* does support creating that
record, but the commandline tool sometimes creates it and sometimes
doesn't. I don't know when it does and doesn't; as noted above, it
didn't when I tried it. A colleague tried it with a different
commandline, and got the config record.
As far as the libav* implementation, it appears that in order for that
record to be created, some metadata has to be set up with the codec
before the stream header is written. And that metadata isn't set up
unless you set the flag CODEC_FLAG_GLOBAL_HEADER on the codec *before*
it is opened.
The following is the code that I originally got from some sample code
(the "flv" format is one of those which has the AVFMT_GLOBALHEADER flag
set, so this works):
// some formats want stream headers to be separate
if(formatCtx_->oformat->flags & AVFMT_GLOBALHEADER)
codecCtx_->flags |= CODEC_FLAG_GLOBAL_HEADER;
but it was never clear to me whether I really needed this, who used it,
and when. I had just pasted it in at the bottom of my muxer (and codec)
init code, for lack of a better place. All I had to do was move it
above the avcodec_open() function call, and voila, the decoder config
record was created and video played.
Andy
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user