SuRGeoNix / Flyleaf

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

Part of video is SOMETIMES gray when stepping through video #386

Closed Symbai closed 9 months ago

Symbai commented 9 months ago

For SOME videos only part of the video is SOMETIMES gray when stepping through. When saying sometimes its mostly when I step backwards or forward by 60 seconds. However when I step forward through it by only 10 seconds its NOT gray. Even at the same timestamp.

So lets say video position is 00:00:00. I step by +60 seconds to 00:01:00 => part of video is gray I go back to 00:00:00 I step by +10 seconds 6 times to 00:01:00 => NOT gray

But now comes the fun: So lets say video position is 00:01:00. I step by +10 seconds to 00:01:10 => NOT gray I step by +10 seconds to 00:01:20 => NOT gray I step by -10 seconds BACK to 00:01:10 => part of the video is gray

The video plays perfectly fine. I only see the gray parts when video is paused and I step through it. I dont see these issues on other players.

Here is a screenshot of how it looks when its gray image

And here is the media info:

General
Format                         : MPEG-TS
Overall bit rate mode          : Variable
Overall bit rate               : 6 177 kb/s
Frame rate                     : 60.000 FPS

Video
ID                             : 256 (0x100)
Menu ID                        : 1 (0x1)
Format                         : AVC
Format/Info                    : Advanced Video Codec
Format profile                 : Constrained High@L4.2
Format settings                : CABAC / 2 Ref Frames
Format settings, CABAC         : Yes
Format settings, Reference fra : 2 frames
Format settings, GOP           : M=1, N=30
Codec ID                       : 27
Duration                       : 2 h 14 min
Width                          : 1 920 pixels
Height                         : 1 080 pixels
Display aspect ratio           : 16:9
Frame rate                     : 60.000 FPS
Color space                    : YUV
Chroma subsampling             : 4:2:0
Bit depth                      : 8 bits
Scan type                      : Progressive

From what I can tell the main difference in media info is the "2 Ref Frames". Other videos dont having this issue looks like:

Format settings                : CABAC / 1 Ref Frames
Format settings, CABAC         : Yes
Format settings, Reference fra : 1 frame
Format settings, GOP           : M=1, N=15
SuRGeoNix commented 9 months ago

@Symbai Can you provide a sample video (and logs!) to reproduce it? I've already tried few mpeg-ts formats with no success

I would try to enable/disable video acceleration and change the video processor (from flyleaf to d3d11) to see if that fixes it

Symbai commented 9 months ago

provide a sample video

Not in public

I would try to enable/disable video acceleration and change the video processor (from flyleaf to d3d11) to see if that fixes it

How do I do this?

SuRGeoNix commented 9 months ago

Drop me an email. If you use Sample binary just from video settings otherwise

Config.Video.VideoAcceleration = false;
Config.Video.VideoProcessor = VideoProcessors.D3D11;
Symbai commented 9 months ago

gray

Config.Video.VideoAcceleration = true;
Config.Video.VideoProcessor = FlyleafLib.VideoProcessors.D3D11;

NOT gray (but the part which would be gray is broken / squeezed)

Config.Video.VideoAcceleration = false;
Config.Video.VideoProcessor = FlyleafLib.VideoProcessors.D3D11;

image gray

Config.Video.VideoAcceleration = true;
Config.Video.VideoProcessor = FlyleafLib.VideoProcessors.Flyleaf;

NOT gray (but the part which would be gray is broken / squeezed like screenshot above)

Config.Video.VideoAcceleration = false;
Config.Video.VideoProcessor = FlyleafLib.VideoProcessors.D3D11;

Will send you an email shortly.

Symbai commented 9 months ago

Email sent

SuRGeoNix commented 9 months ago

@Symbai that's an FFmpeg bug. It seems that it happens also with VLC (make sure you have from Tools->Preferences->All->Demuxers the AVFormat demuxer selected).

Symbai commented 9 months ago

That's weird if I use ffmpeg with -avoid_negative_ts make_zero -vcodec copy -acodec copy the output file doesn't have this gray issue. If its an ffmeg bug how can ffmpeg correct this issue then?

Edit: I can reproduce with VLC. However on VLC this occurs ALWAYS. Using Flyleaf this does not (see the +10 / -10 seconds example in first post)

Symbai commented 9 months ago

You're right its either ffmpeg or broken video file. I used ffmpeg to retrieve thumbnail at 55 seconds and it detects a "corrupt frame" but I get the "squeezed" result so its definitely not Flyleaf.

SuRGeoNix commented 9 months ago

Btw, I tried a couple of things to fix this as workaround without success. I think I've seen in ffmpeg trac a similar issue but I couldn't find it. It's not the file though it's the ffmpeg issue. As vlc with default demuxer works fine.

Symbai commented 9 months ago

My workaround is that I'm using ffmpeg -i a.ts -c copy a2.ts this fixes the issue and only takes a couple of seconds even on a long video. It just feels weird that whatever ffmpeg is doing there it obviously CAN deal with it, but only when creating a new file.