How can I call to subprocess with input and output as file-like variables?

Hello I am triying to callo to ffmpeg from ubuntu, the idea is set the input a file-like object get from s3 apply a filter and upload again without write locally, the code that The first try was the following code

import subprocess
import boto3
from io import BytesIO

s3_client = boto3.client('s3')

f = BytesIO()
s3_client.download_fileobj('video', '15_19_12.mkv', f)

result =['ffmpeg', "-codec copy", "aaa.mp4"], input=f.getbuffer())

But I this doesn't recognice args like "-codec copu"

Then I update to

proc = subprocess.Popen(['ffmpeg', "-codec", "copy"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = proc.communicate(input=f.getbuffer())

in this case, doesnt recognice the input

So how can I use Popen or another in order to set f.getbuffer and get the output file in another Bytes?


How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum