AkarinVS / L-SMASH-Works

Works based on L-SMASH project; This repo focuses on the common portion and the VapourSynth plugin. AviSynth users please use https://github.com/HomeOfAviSynthPlusEvolution/L-SMASH-Works. ffmpeg 5.0+ please use ffmpeg-4.5 branch.
47 stars 11 forks source link

Frame error with VapourSynth (but works in Avisynth) #12

Open mysteryx93 opened 2 years ago

mysteryx93 commented 2 years ago

Encoding GoPro 5K footage. Using StaxRip editor, with x265 it encodes fine, but with NVenc for hardware acceleration, it always freezes at about 99%. No warning or anything. When it freezes, it says "729/748" frames.

x265 encodes fine but gives a warning Code: vpy [FLAW]: error occurred while reading frame 747 In Avisynth, it encodes fine both with x265 and NVenc. (with LSMashSource)

Final test, using Vapoursynth with ffms2 source and NVenc. Worked flawlessly.

The problem is LSMashSource for VapourSynth.

Here's a sample GoPro video

AkarinVS commented 2 years ago

Any test videos showing the issue? Which version of lsmas are you using?

AkarinVS commented 2 years ago

Thanks for the test clip and I have reproduced the issue: Error: Failed to retrieve frame 747 with error: lsmas: failed to output a video frame.

It affects both LWLibavSource and LibavSMASHSource, but does not affect ffms2 compiled with the same FFmpeg. Will investigate.

AkarinVS commented 2 years ago

The video file is invalid in that the last two frames both contain the same poc (26). ffms2 ignores the error but lsmas is more picky.

If you use a player like mpv and seek to the last frame, you will see the following error from ffmpeg as well: [ffmpeg/video] hevc: Duplicate POC in a sequence: 26. [ffmpeg/video] hevc: Error parsing NAL unit #0. Error while decoding frame!

The same error will show if you add ff_loglevel=3 to show error messages from ffmpeg, you will also see the error: [hevc @ 0x7fcd16053c00] Duplicate POC in a sequence: 26

I'm not sure why avisynth could handle this file. But if given an invalid video file, there is no guarantee that lsmas can read the file. We could make lsmas less strict and handle this case, but it will be a lower priority issue.