SuRGeoNix / Flyleaf

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

Invalid FPS with dshow usb camera #514

Open LazyCuteLion opened 1 week ago

LazyCuteLion commented 1 week ago

when play with camera, i choose the menu-item[MJPG,1920x1080,30FPS],but actually play with [YUY2,1920x1080,5FPS].

LazyCuteLion commented 1 week ago

check the log,it seems to be ffmpeg? Flyleaf Log: 16.30.18.214 | Debug | [#1] [Demuxer: Main] Opening -> Stopped 16.30.18.226 | Debug | [#1] [Decoder: Video] Stopped -> Opening 16.30.18.238 | Info | [#1] [Decoder: Video] VA AV_CODEC_IDMJPEG not supported 16.30.18.246 | Info | [#1] [Demuxer: Main] [Video #0] Enabled 16.30.18.251 | Debug | [#1] [Decoder: Video] Opening -> Stopped 16.30.18.261 | Info | [#1] [DecoderContext] [OpenVideoStream] # => #0 16.30.18.282 | Info | [#1] [DecoderContext] [OpenPlaylistItem] None => 16.30.18.288 | Info | [#1] [DecoderContext] [Open] fmt://dshow?video=USB Camera&video_size=1920x1080&framerate=30&vcodec=mjpeg 16.30.18.311 | Debug | [#1] [Player ] OnBufferingStarted 16.30.18.319 | Debug | [#1] [Demuxer: Main] Stopped -> Running 16.30.18.325 | Debug | [#1] [Decoder: Video] Stopped -> Running 16.30.18.340 | Debug | [#1] [Demuxer: Main] Thread started (Running) 16.30.18.349 | Debug | [#1] [Decoder: Video] Thread started (Running) 16.30.18.383 | Debug | [#1] [Renderer ] Preparing planes for yuvj422p with Flyleaf 16.30.18.410 | Debug | [#1] [Renderer ] Prepared planes for yuvj422p with Flyleaf [YUVPlanar] 16.30.18.730 | Info | [#1] [Player ] Started [V: 00:00:00.0333337] 16.30.18.735 | Debug | [#1] [Player ] OnBufferingCompleted

FFmpeg Log: FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=d8 avail_size_in_buf=280550 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker parser used 0 bytes (0 bits) FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=db avail_size_in_buf=280548 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] index=0 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] qscale[0]: 1 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker parser used 67 bytes (536 bits) FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=db avail_size_in_buf=280479 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] index=1 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] qscale[1]: 2 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker parser used 67 bytes (536 bits) FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=c0 avail_size_in_buf=280410 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] Changing bps from 0 to 8 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] sof0: picture: 1920x1080 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] component 0 2:1 id: 0 quant:0 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] component 1 1:1 id: 1 quant:1 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] component 2 1:1 id: 2 quant:1 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] pix fmt id 21111100 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] Format yuvj422p chosen by get_format(). FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker parser used 17 bytes (136 bits) FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=c4 avail_size_in_buf=280391 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker parser used 0 bytes (0 bits) FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=c4 avail_size_in_buf=280358 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker parser used 0 bytes (0 bits) FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=c4 avail_size_in_buf=280175 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker parser used 0 bytes (0 bits) FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=c4 avail_size_in_buf=280142 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker parser used 0 bytes (0 bits) FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=dd avail_size_in_buf=279959 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker parser used 0 bytes (0 bits) FFmpeg|Debug |[mjpeg @ 0000021f04955e40] escaping removed 590 bytes FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=da avail_size_in_buf=279953 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker parser used 279363 bytes (2234904 bits) FFmpeg|Debug |[mjpeg @ 0000021f04955e40] marker=d9 avail_size_in_buf=0 FFmpeg|Debug |[mjpeg @ 0000021f04955e40] decode frame unused 0 bytes FFmpeg|Debug |[dshow @ 0000021f049513c0] All info found

SuRGeoNix commented 1 week ago

Hi @LazyCuteLion, flyleaf sets the proper ffmpeg parameters so I guess is an issue with FFmpeg? Can you try ffmpeg itself?

LazyCuteLion commented 1 week ago

ffmpeg can not play , i tested by ffplay,it is ok. en,i think it is because of ffmpeg.

LazyCuteLion commented 1 week ago

if use ffmpeg to record a video (command:ffmpeg -f dshow -video_size 1920x1080 -framerate 30 -vcodec mjpeg -i video="USB Camera" "D:\xxxx.mp4") it is ok. so,what is wrong?

SuRGeoNix commented 2 days ago

There is no point to test the FFmpeg if you transcode it to mp4 for example. Did you say that ffplay works or not? Possible try mpv as well?

LazyCuteLion commented 1 day ago

ffplay work, the command:-f dshow -video_size 1920x1080 -framerate 30 -vcodec mjpeg -i video="USB Camera" mpv,i try it, only play "av://dshow:video=USB Camera", when i add the parameters it doesn't work.(av://dshow:video=USB Camera:width=1920:height=1080:fps=30,I'm not familiar with mpv,can you give me the right url?)

SuRGeoNix commented 1 day ago

I can't think how Flyleaf will change the framerate itself. So something is wrong with ffmpeg and framerate parameter in your case. Wondering if FFmpeg version 5/6 have both the same issue. I will need to test it with a camera and reproduce it myself but to be honest, nobody complained for such an issue so far. Might something specific with your case.

A trace log would help (both for flyleaf and ffmpeg)

LazyCuteLion commented 12 hours ago

check the log(disable HW): 10.07.47.437 | Info | [#1] [Player ] Opening fmt://dshow?video=USB Camera&video_size=1920x1080&framerate=30&vcodec=mjpeg 10.07.47.444 | Debug | [#1] [Player ] Initializing 10.07.47.469 | Debug | [#1] [Player ] Initialized 10.07.47.503 | Info | [#1] [PluginHandler ] [OpenDefault] Open Success 10.07.47.510 | Info | [#1] [PluginHandler ] SuggestItem #0 - 10.07.47.525 | Info | [#1] [PluginHandler ] [OpenDefault] Open Item (0) Success 10.07.47.553 | Debug | [#1] [Demuxer: Main] Stopped -> Opening 10.07.47.726 | Debug | [#1] [Demuxer: Main] Ignoring format option reconnect 10.07.47.730 | Debug | [#1] [Demuxer: Main] Ignoring format option reconnect_streamed 10.07.47.733 | Debug | [#1] [Demuxer: Main] Ignoring format option reconnect_delay_max 10.07.47.736 | Debug | [#1] [Demuxer: Main] Ignoring format option user_agent 10.07.47.740 | Debug | [#1] [Demuxer: Main] Ignoring format option http_persistent 10.07.47.744 | Debug | [#1] [Demuxer: Main] Ignoring format option rtsp_transport 10.07.47.747 | Debug | [#1] [Demuxer: Main] Ignoring format option vcodec 10.07.48.100 | Info | [#1] [Demuxer: Main] Format Context Info [Format ] DirectShow capture/dshow | | 45.17:50:43.3893680/00:00:00 | 45.17:50:43.3893680/00:00:00 [Video #0] mjpeg yuvj422p 1920x1080 @ 30 | [Color: BT601] [BR: 0] | 45.17:50:43.3893684/-10675199.02:48:05.4775808 | 45.17:50:43.3893684/00:00:00

last line is same to ffmpeg itself ( Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/bt709/unknown), 1920x1080, 30 fps, 30 tbr, 10000k tbn). maybe ,it is Flyeaf can not be handled correctly the pixel format of yuvj422p? Anyway, it's not really important. should we close this issues?

LazyCuteLion commented 12 hours ago

Besides, you don't seem to have noticed of [#498]? I'd rather you answered there than here.

SuRGeoNix commented 4 hours ago

I don't think this is an issue with Pixel Format. I think is an issue with timestamps, that's why I asked you for flyleaf's trace log. It's an issue so let it be open and might review this in the future (will try to reproduce it).