BogdanovKirill / RtspClientSharp

Pure C# RTSP client for .NET Standard without external dependencies and with true async nature. I welcome contributions.
MIT License
708 stars 284 forks source link

Frame decoding errors when streaming rtsp via ffserver. B-frames supporting needed. #39

Open IvanovNiko opened 5 years ago

IvanovNiko commented 5 years ago

Kirill, hi.

We are tested our program which integrated RtspClientSharp library and streamed video from different sources. We tested the streaming video files via ffserver and found the problem in libffmpeghelper library. When we got RawH264IFrame - parsing is ok, and when we got RawH264PFrame - frame decoding failed in function FFmpegVideoPInvoke.DecodeFrame(_decoderHandle, (IntPtr)rawBufferPtr, rawVideoFrame.FrameSegment.Count, out int width, out int height, out FFmpegPixelFormat pixelFormat); The result code of FFmpegVideoPInvoke.DecodeFrame was -4 - it's an error code from libffmpeghelper.dll. Vlc player show correct video from ffserver videostream, but SimpleRtspPlayer show bad video (some frames are lost).

Could you help us to solve this problem? I can to describe how to reproduce the issue more detailed if needed - i have a test video file, ffserver commands to stream the video.

Thanks.

BogdanovKirill commented 5 years ago

Hello,

Could you provide me your test file and command arguments for ffserver?

IvanovNiko commented 5 years ago

Kirill, hi.

I shared the file in google.drive (vlc reprodice it excellent without problems) - https://drive.google.com/open?id=1xuhXV6P8CfB9xroBvFKQChnEhb99ddVX This file you must put in folder with ffserver.exe

ffserver.config

RTSPPort 554

<Stream rtsp.win>
  Format rtp
  File 3.mkv
</Stream>

ffserver run command ffserver -d -f ffserver.config

IvanovNiko commented 5 years ago

Kirill, hi.

Have you any news on the problem? Are you confirm that is it a problem in decoding librarary?

BogdanovKirill commented 5 years ago

Hello,

Sorry, I don't have free time to understand where problem is. It seems that this video contains B-frames which are not implemented

IvanovNiko commented 5 years ago

Hi.

Thanks for your answer. Does B-frames not implemented in RtspClientSharp library or in decoder library? And how can i to diagnostic that problem?

BogdanovKirill commented 5 years ago

B-frames are not impelemented in RtspClientSharp because most of real time rtsp sources doesn't use them. You could try to debug H264Parser.cs, especially ProcessNalUnit/TryGenerateFrame

IvanovNiko commented 5 years ago

Hi.

Yes, you are right. The video contains B-frames. I saw it over ffprobe and in debug mode (slice_type is equal to 6 in H264Parser module).

Kirill, are you planning to implement B-frames in future? And why did it not implemented yet? Is implementation very difficult?

Thank you

BogdanovKirill commented 5 years ago

Hello,

Yes, I will implement in future. I think it's not very difficult, just need some time

IvanovNiko commented 5 years ago

Ok, it super. I will wait.

Thank you.