SuRGeoNix / Flyleaf

Media Player .NET Library for WinUI 3/ WPF/WinForms (based on FFmpeg/DirectX)
GNU Lesser General Public License v3.0
687 stars 92 forks source link

Fix video changing on network stream not updating player to correct width/height #439

Closed coldays closed 3 months ago

coldays commented 4 months ago

When playing network streams, if the video changes the player does not update width/height. This change checks when receiving frame from decoder if width or height has changed.

How to test:

  1. Start a network stream, e.g.: ffmpeg -re -i my_test_video.ts -c copy -f mpegts udp://238.255.255.255:1234
  2. Start playback with the url
  3. After the player has started playing run taskkill -f -im ffmpeg.exe && ffmpeg -re -i my_other_test_video.ts -c copy -f mpegts udp://238.255.255.255:1234 This assumes the two videos has different resolutions
SuRGeoNix commented 4 months ago

@coldays Can you confirm that this is only for software decoding until I will review this in detail? If I remember right, that was working already for hardware decoding.

coldays commented 4 months ago

Looks like to me that only happens in VideoDecoder.get_format when constructing it. I assume in between playing different files/streams This proposed change checks decoded frames while playing. It does not reconstruct hw frame, but maybe it should

coldays commented 4 months ago

Alternatively we can listen to the return value of avcodec_send_packet. If it returns AVERROR_INPUT_CHANGED, we need to set up the decoder/demuxer again. This might be more robust