SuRGeoNix/Flyleaf

Hello, may I ask how to play such data?

Closed this issue · 2 comments

I am using FlyLeaf to create a player for a camera. This camera only supports the "SSP" protocol, and now I have used this protocol to achieve the following effect:
Utilize FFMPEG AUTOGEN, cache videos and audio as TS files, and these files can be played normally.
Now, I also need to play the video data in FlyLeaf while receiving it. This is part of my code for processing video data. If you have time, can you tell me how to use FlyLeaf to play it? Thank you.

private void OnVideoDataReceived(SspH264Data data)
        {
            if (data.data == IntPtr.Zero || data.len == 0) {  return; }
            byte[] byteArray = new byte[data.len];
            Marshal.Copy(data.data, byteArray, 0, (int)data.len);
            fixed (byte* pBuffer = byteArray)
            {
                AVPacket* packet = ffmpeg.av_packet_alloc();
                packet->data = pBuffer;
                packet->size = (int)data.len;
                packet->pts = (long)data.pts;
                ffmpeg.av_packet_rescale_ts(packet, vRationaReal, vRationalTarget);
                packet->dts = packet->pts;
                packet->stream_index = 0;

                ffmpeg.av_interleaved_write_frame(outputFormatContextCache, packet);
                ffmpeg.av_packet_unref(packet);
            }
        }

Hi @void-soul,

I'm not sure how SSP works but from what I see you will need a to use a Custom IO Stream and override the Read method which will be used by FFmpeg. You might need to force the format and even the codecs to make this work properly. You can use an external audio stream (separate custom IO Stream) if you can't use the same for both audio/video. Have a look on same examples from other users:-

#291
#348

Let me know how it goes and if you need more help.

Thank you for your reply. I have reviewed the two issues you provided and my situation is almost the same as #348 so it is now working normally. Thank you very much!