in flash player, how to play h.264 stream immediately

162 Views Asked by At

There's a server, which sends an AVCDecoderConfigurationRecord tag and continuous H264 video tags. In the client, I use NetStream and appendBytes (Data Generation Mode) to display the video. The code likes that

video = new Video
addChild(vdieo)

socket = new Socket
socket.connect(server)
socket.addEventListener(SOCEKT_DATA, onRecv)

nc = new NetConnection
nc.connect(null)
ns = new NetStream(nc)
ns.client = this
ns.play(null)
video.attachNetStream(ns)

function onRecv(e) : void {
    data = new ByteArray
     socket.readBytes(data)
     if (data-is-AVCDecoderConfigurationRecord-tag) {
          ns.appendBytesAction(RESET_BEGIN)
     }
     ns.appendBytes(data)
}

The client works, howerver, the NetStream does not start palying the video until it caches about 20 tags into the buffer (about 2 seconds, because the fps is 10). It does not satisfy my requirement that I need to play the stream immediately while the client receives a tag. I set the bufferTime = 0 or other small number, there's no effect, waiting about 20 tags as usual. While I set the bufferTime bigger such as 5, it works that NetStream waiting more tags.

END_SEQUENCE Constant

public static const END_SEQUENCE:String = "endSequence" Indicates that the media stream data is complete. For some codecs, such as H.264, the byte parser waits for the buffer to fill to a certain point before beginning playback. Pass END_SEQUENCE to tell the byte parser to begin playback immediately.

In Adobe document, I find this information and I try to use the END_SEQUENCE several ways, but all of them do not work. Is there a way to play the H264 tag immediately without buffer?

0

There are 0 best solutions below