2

Here is the Python code:

import subprocess 

cmnd = ["ffmpeg", "-i", "/home/xincoz/test/connect.flv", "-acodec", "copy", "-ss", "00:00:00", "-t", "00:00:30", "/home/xincoz/test/output.flv"]

subprocess.call(cmnd)

Here I get the 30sec long video output file output.flv from connect.flv video. But i want to store that 30sec long binary data in a variable instead of copying that into an output file. How can I able to do that?

Please help me. Thanks a lot in advance.

1

1 Answer 1

3

You'll have to tell to ffmpeg to output to stdout and also tell if the output format. Then from python, as @matino said, use Popen to read what was written to stdout:

cmnd = ["ffmpeg", "-i", "/your/file.avi", "-acodec", "copy", "-ss", "00:00:00", "-t", "00:00:30", "-f", "avi", "pipe:1"]

p = subprocess.Popen(cmnd, stdout=subprocess.PIPE)

out, err = p.communicate()

print len(out) # print the length of the data received
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.