0

I have a streaming m3u8 links (one for video and one for audio)that I want to merge.

I've been doing this command line to do so:

ffmpeg  -i <audio> -i <video? -async 1 -c copy output.mp4

and it works just like I want, the problem is I am trying to do this for 100 different link, and I would like to write a code instead of doing this manually for each link. I know that this can be done in python, but I don't know how to translate an ffmpeg command to a python code.

2
  • Can you provide audio/video links examples? Commented Apr 8, 2019 at 0:41
  • os.system("ffmpeg -i <audio> -i <video> -async 1 -c copy output.mp4") Commented Apr 8, 2019 at 0:42

2 Answers 2

1

Run code without catching displayed text

import os
os.system("ffmpeg -i <audio> -i <video> -async 1 -c copy output.mp4")

subprocess has different methods

import subprocess

subprocess.run("ffmpeg -i <audio> -i <video> -async 1 -c copy output.mp4", shell=True)

subprocess.run( ["ffmpeg", "-i", "<audio>", "-i", "<video>", "-async", "1", "-c", "copy", "output.mp4"] )

Other methods can catch displayed text so you can check result.

Sign up to request clarification or add additional context in comments.

Comments

0

I used the code furas suggested and it worked:

import os
import pandas as pd 

D=pd.read_excel("links.xlsx");


for i in range(len(D.index)):
    video=D.iat[i,0]
    audio=D.iat[i,1]
    command='ffmpeg  -i '+audio+' -i '+video+' -async 1 -c copy '+str(i)+'.mp4'
    os.system(command)

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.