I have an issue with FLV stream generating. I've developed DVR system, an it should be able to stream video in FLV format (to play it on Actionscript NetStream). I receive video from encoder in raw H264 NAL units (0x00 0x00 0x00 0x01 ), also I can recognize is encoded frame IDR or non-IDR.
My solution to create FLV stream (based on Adobe spec: Video File Format Specification Version 10) was:
Stream looks good, and can be playable by ffplay, mplayer, vlc, etc. But not played by player based on Actionscript NetStream.
So, I've get raw h264 data and convert it to FLV using ffmpeg:
ffmpeg -f h264 -i d1.h264 -vcodec copy -f flv d1.flv
and try to compate both flv's my and ffmpeg's.
First of all I see that ffmpeg adds AVC sequence header, immediately after FLV header. I've started to do the same, but NetStream still not support my stream, and also another players ceased to play it.
Ok, then I've continue to compare flv's. Now I see that NAL unit headers in ffmpeg's coded FLV a bit changed, but I can't understand what the meaning of the changes. I read many specs, but nothing helpful. Did anybody can clarify me this?
Fo example my NAL units looks so: 00 00 00 01 XX XX ... - for all units
FFmpeg NALs: 00 00 [14 BA] 61 9A ... - non IDR (two bytes variable) 00 00 [7A 02] 65 88 ... - IDR (two bytes variable) 00 00 00 40 06 05 ... - SEI
Is there added some counter or anything else?
Will be happy to see any ideas, links, etc.
Try to use following command to do the work:
ffmpeg -y -i test.flv -vcodec copy -vbsf h264_mp4toannexb test.h264
You will got a vlc playable .h264 file, all NAL is begin with 00 00 00 01.
There are two common H.264 bitstream packing formats.
You are creating annex B but it seems like you need mp4 packing format (length prefixed) for FLV. You have to remove (00) 00 00 01 and add the length as prefix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With