abhiTronix/deffcode

[Question]: while input stream have stop , deffcode will not stop but just hold on

Opened this issue · 2 comments

Issue guidelines

Issue Checklist

  • I have searched open or closed issues for my problem and found nothing related or helpful.
  • I have read the Documentation and found nothing related to my problem.

Describe your Question

source: 'rtmp://xxxx/live/xxx' is a online stream
while the online stream haved close, my code will not stop but just hold on

Terminal log output(Optional)

No response

Python Code(Optional)

def test():
    ffparams = {
        "-vcodec": "h264_cuvid",
        "-debug": 1,
        "-ffprefixes": [
            "-vsync", "0",
            "-hwaccel_device", "0",
            "-hwaccel", "cuda",
        ],
        "-custom_resolution": "null",
        "-framerate": "null",
    }
    source = 'rtmp://xxxx/live/xxx'
    videoDecoder = VideoDecode(source=source, ffparams=ffparams)
    decoder = videoDecoder.decode(verbose=True)
    while True:
        try:
            frame = next(decoder.generateFrame(), None)
            if frame is None:
                break
        except Exception as e:
            print(e)

if __name__ == '__main__':
    test()

DeFFcode Version

0.2.5

Python version

3.8

Operating System version

nvcr.io/nvidia/tensorrt:22.04-py3 and ffmpeg gpu

Any other Relevant Information?

No response

i have to stop by KeyboardInterrupt
rtmp @ 0x555986dfd140] Sending bytes read report0:00:11.16 bitrate=1244160.0kbits/s speed= 1.8x
^CTraceback (most recent call last):1150kB time=00:00:20.88 bitrate=1244160.0kbits/s speed=1.34x
File "test_infer.py", line 120, in
test()
File "test_infer.py", line 110, in test
frame = next(decoder.generateFrame(), None)
File "/usr/local/lib/python3.8/dist-packages/deffcode/ffdecoder.py", line 711, in generateFrame
frame = self.__fetchNextFrame()
File "/usr/local/lib/python3.8/dist-packages/deffcode/ffdecoder.py", line 673, in __fetchNextFrame
frame = self.__fetchNextfromPipeline()
File "/usr/local/lib/python3.8/dist-packages/deffcode/ffdecoder.py", line 655, in __fetchNextfromPipeline
self.__process.stdout.read(
KeyboardInterrupt

@wuqingzhou828 That is because you're processing frames in GPU memory which is separated from main thread and will continue to process until you manually kill the process or send SIGINT signal to terminate process. However I can add a flag to kill process immediately, I'll look into that,