libopenshot icon indicating copy to clipboard operation
libopenshot copied to clipboard

`libopenshot` crash on all `nvenc` codecs

Open aperture147 opened this issue 9 months ago • 0 comments

Hi, I'm building pyopenshot and libopenshot from scratch. For some reason libopenshot crash whenever I use codec h264_nvenc. This is an example code I ran:

from openshot import FFmpegReader, FFmpegWriter, Settings
from contextlib import contextmanager
from typing import TypeVar, Generator

T = TypeVar('T')

@contextmanager
def openshot_closing(reader: T) -> Generator[T, None, None]:
    try:
        reader.Open()
        yield reader
    finally:
        if reader.IsOpen():
            reader.Close()

setting_instance = Settings.Instance()
setting_instance.DEBUG_TO_STDERR = True 
setting_instance.HARDWARE_DECODER = 2 # setting encoder/decoder to cuda
setting_instance.HW_DE_DEVICE_SET = 0
setting_instance.HW_EN_DEVICE_SET = 0


with openshot_closing(FFmpegReader('video.mp4')) as reader:
    writer = FFmpegWriter('video_out.mp4')
    writer.SetVideoOptions(
        True,
        'h264_nvenc', # also crashed on `hevc_nvenc`
        reader.info.fps, reader.info.width, reader.info.height,
        reader.info.pixel_ratio, reader.info.interlaced_frame, reader.info.top_field_first, reader.info.video_bit_rate)
    with openshot_closing(writer) as c_writer:
        c_writer.WriteFrame(reader, 0, reader.info.video_length)

I've also obtained a log file from running this script (2k of lines): log.txt

As mentioned in #890 , FFmpegWriter crashed and closed on frame 33, with this error (line 2093 in log.txt):

FFmpegWriter::write_video_packet ERROR [Invalid argument] (result=-22.0000)

The code above runs fine if I switch to libx264, libx265 or libvpx.

aperture147 avatar May 13 '24 10:05 aperture147