Python FFMPEG,正在运行子进程,获取错误:“;管道::处理输入时发现无效数据;

Python FFMPEG,正在运行子进程,获取错误:“;管道::处理输入时发现无效数据;,python,ffmpeg,subprocess,Python,Ffmpeg,Subprocess,我正在写一个程序,从ip摄像机中获取流,做我需要的帧并发送到ffmpeg进行转码。然后ffmpeg应该转换视频并发送到输出url。 但当我运行脚本时,我得到了错误:“管道::处理输入时发现无效数据”。 我在ffmpeg方面真的是个新手。请帮忙,我做错了什么 cap = cv2.VideoCapture("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov") command = [ "ffmpeg",

我正在写一个程序,从ip摄像机中获取流,做我需要的帧并发送到ffmpeg进行转码。然后ffmpeg应该转换视频并发送到输出url。 但当我运行脚本时,我得到了错误:“管道::处理输入时发现无效数据”。 我在ffmpeg方面真的是个新手。请帮忙,我做错了什么


cap = cv2.VideoCapture("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov")

command = [
    "ffmpeg",
    "-i", "-",
    "-f", "mpegts",
    "-vcodec", "mpeg1video",
    "-s", "960x540",
    "-b:v", "1000K",
    "-r", "30",
    "-bf", "0",
    "-codec:a", "mp2",

    "http://127.0.0.1:8888/yoursecret"
]

proc = subprocess.Popen(command, stderr=subprocess.PIPE, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
out, err = proc.communicate()


print(err)

while True:
    ret, frame = cap.read()
    # _, buf = cv2.imencode('.jpg', frame)
    # img_byte = io.BytesIO(buf.tobytes())
    try: 
        proc.stdin.write(frame.tostring())
        print("SENDED")
    except IOError as e:
        print(e) 
        proc.stdin.close()
        proc.wait() 

proc.stdin.close()
proc.wait()
回溯

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
pipe:: Invalid data found when processing input

你能更新完整的错误跟踪吗?你能更新完整的错误跟踪吗