hozuki / MonoGame.Extended2

A collection of extensions for MonoGame
BSD 3-Clause Clear License
39 stars 8 forks source link

VideoPlayback: Support for RTMP/streams? #8

Open akechi-haruka opened 10 months ago

akechi-haruka commented 10 months ago

Hi, your VideoPlayer library seems to be exactly the thing I need, however I can't seem to get it to work with RTMP, calling VideoHelper.LoadFromUrl(@"rtmp://*****").

I had to make a couple adjustments to the code around detecting playback end (since streams have no defined length, so the status is mistakenly set to MediaState.Stopped in some cases), however I am still unable to get any frames displayed, as it seems to permanently block at DecodeContext.cs:1097 ffmpeg.av_read_frame(FormatContext, packet.RawPacket); If I enable FFMPEG log output, I can however see that frames are being received. The RTMP stream also works, since I can get working playback by running ffplay rtmp://***** -x 1024 -y 600 -max_delay 0 -max_probe_packets 1 -analyzeduration 0 -flags +low_delay -fflags +nobuffer.

Any idea?

Log output:

Using FFmpeg version n5.1.2-4-gf5455889fd-20221020
[FFMPEG][NULL @ 000001dfeca76580] [debug] Opening 'rtmp://****' for reading

[FFMPEG][rtmp @ 000001dfeca79cc0] [debug] No default whitelist set

[FFMPEG][tcp @ 000001dfeca79dc0] [debug] No default whitelist set

[FFMPEG][tcp @ 000001dfeca79dc0] [debug] Original list of addresses:

[FFMPEG][tcp @ 000001dfeca79dc0] [debug] Address *** port 1935

[FFMPEG][tcp @ 000001dfeca79dc0] [debug] Interleaved list of addresses:

[FFMPEG][tcp @ 000001dfeca79dc0] [debug] Address *** port 1935

[FFMPEG][tcp @ 000001dfeca79dc0] [verbose] Starting connection attempt to *** port 1935

[FFMPEG][tcp @ 000001dfeca79dc0] [verbose] Successfully connected to *** port 1935

[FFMPEG][rtmp @ 000001dfeca79cc0] [debug] Handshaking...

[FFMPEG][rtmp @ 000001dfeca79cc0] [debug] Type answer 3

[FFMPEG][rtmp @ 000001dfeca79cc0] [debug] Server version 13.14.10.13

[FFMPEG][rtmp @ 000001dfeca79cc0] [debug] Proto = rtmp, path = ***, app = ***, fname = ***

[FFMPEG][rtmp @ 000001dfeca79cc0] [debug] Window acknowledgement size = 5000000

[FFMPEG][rtmp @ 000001dfeca79cc0] [debug] Max sent, unacked = 5000000

[FFMPEG][rtmp @ 000001dfeca79cc0] [debug] New incoming chunk size = 4096

[FFMPEG][rtmp @ 000001dfeca79cc0] [debug] Creating stream...

[FFMPEG][rtmp @ 000001dfeca79cc0] [debug] Sending play command for '****'

[FFMPEG][trace] Probing flv score:100 size:2048

[FFMPEG][flv @ 000001dfeca76580] [debug] Format flv probed with size=2048 and score=100

[FFMPEG][flv @ 000001dfeca76580] [debug] Before avformat_find_stream_info() pos: 13 bytes read:2063 seeks:0 nb_streams:0

[FFMPEG][flv @ 000001dfeca76580] [trace] type:18, size:24, last:-1, dts:0 pos:21

[FFMPEG][flv @ 000001dfeca76580] [trace] type:18, size:387, last:-1, dts:0 pos:60

[FFMPEG][flv @ 000001dfeca76580] [trace] type:8, size:7, last:-1, dts:4845899 pos:462

[FFMPEG][flv @ 000001dfeca76580] [trace] 1 AF 0 

[FFMPEG][flv @ 000001dfeca76580] [trace] type:8, size:8, last:-1, dts:4845921 pos:484

[FFMPEG][flv @ 000001dfeca76580] [trace] 1 AF 0 

[FFMPEG][flv @ 000001dfeca76580] [trace] type:8, size:8, last:-1, dts:4845942 pos:507

[FFMPEG][flv @ 000001dfeca76580] [trace] 1 AF 0 

[FFMPEG][flv @ 000001dfeca76580] [trace] type:8, size:8, last:-1, dts:4845963 pos:530