kkroening / ffmpeg-python

Python bindings for FFmpeg - with complex filtering support
Apache License 2.0
10.12k stars 893 forks source link

Pipes not working #484

Open jdbodyfelt opened 3 years ago

jdbodyfelt commented 3 years ago

I'm trying to get pipes working in a class in the following manner

        self.webcam = (
            ffmpeg.input(
                opts["device"],
                format="avfoundation",
                framerate=self.fps,
                pix_fmt="uyvy422",
                s=opts["size"],
                probesize="42M",
            )
            .output("pipe:0", format="rawvideo")
            .run_async(pipe_stdout=True, pipe_stdin=True)
        )
        self.writer = (
            ffmpeg.input("pipe:0", format="rawvideo")
            .output(self.name, pix_fmt="yuv420p")
            .overwrite_output()
            .run_async(pipe_stdin=True)
        )

where opts["device"], opts["size"], self.name, and self.fps are objects within my class. When I call my code, I get the following error

Input #0, avfoundation, from 'HD Pro Webcam C920':
  Duration: N/A, start: 79133.371567, bitrate: N/A
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, rawvideo, to 'pipe:0':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080, q=2-31, 995328 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.91.100 rawvideo
av_interleaved_write_frame(): Bad file descriptor
Error writing trailer of pipe:0: Bad file descriptor
frame=    1 fps=0.0 q=-0.0 Lsize=    4050kB time=00:00:00.03 bitrate=995338.0kbits/s speed=  12x    
video:4050kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Conversion failed!

Not really sure where the problem is on the bad file descriptor? Any advice?

medhini commented 2 years ago

Were you able to figure this out? Facing the same error

whalefa1I commented 1 year ago

Were you able to figure this out? Facing the same error

        process = (
            ffmpeg
                .input(file)
                .output("pipe:", format="rawvideo", pix_fmt="rgb24", s="27*48", vsync="0")
                .run_async( pipe_stdout=True)
        )
        video_stream, err = process.communicate()
liduang commented 9 months ago

I also encountered this problem. Is there a solution?