0
我使用ffmpeg
來創建一個視頻,我從一個base64編碼圖像列表中創建一個視頻,我將其輸入到ffmpeg
。python中的ffmpeg的管道輸入和輸出
輸出到文件(使用下面的連接代碼)的作品完美,但我想實現的是讓輸出到Python的變量,而不是 - 這意味着管道輸入和輸出管道,但我似乎無法得到它的工作
我當前的代碼:
output = os.path.join(screenshots_dir, 'video1.mp4')
cmd_out = ['ffmpeg',
'-y', # (optional) overwrite output file if it exists
'-f', 'image2pipe',
'-vcodec', 'png',
'-r', str(fps), # frames per second
'-i', '-', # The input comes from a pipe
'-vcodec', 'png',
'-qscale', '0',
output]
pipe = sp.Popen(cmd_out, stdin=sp.PIPE)
for screenshot in screenshot_list:
im = Image.open(BytesIO(base64.b64decode(screenshot)))
im.save(pipe.stdin, 'PNG')
pipe.stdin.close()
pipe.wait()
這導致工作MP4,但我想,以避免保存到本地。
與改變output
到'-'
或'pipe:1'
並在誤差加法stdout=sp.PIPE
結果運行相同的代碼
[NULL @ 0x2236000]無法找到合適的輸出格式 '管:'
以及如何將它讀入python變量? – bluesummers
無法幫助您使用python部分。只有ffmpeg。 – Mulvya
無論如何,謝謝你,現在似乎工作。我會看看我是否真的抓住它,並驗證它是視頻,如果是的話,我會接受 – bluesummers