Here I tried to cut first and second 30sec long video file from "path/connect.flv" to the files output1.flv and output2.flv. It works. I able to concatenate these two files to form a new file "final.flv" of 60sec long. So this works and i am getting the outputs output1.flv [30sec], output2.flv[30sec] and final.flv[1min].
Here is the python code:
import subprocess
ffmpeg_command1 = ["ffmpeg", "-i", "/home/xincoz/test/connect.flv", "-acodec", "copy", "-ss", "00:00:00", "-t", "00:00:30", "/home/xincoz/test/output1.flv"]
ffmpeg_command2 = ["ffmpeg", "-i", "/home/xincoz/test/connect.flv", "-acodec", "copy", "-ss", "00:00:30", "-t", "00:00:30", "/home/xincoz/test/output2.flv"]
ffmpeg_command3 = ["mencoder", "-forceidx", "-ovc", "copy", "-oac", "pcm", "-o", "/home/xincoz/test/final.flv", "/home/xincoz/test/output1.flv", "/home/xincoz/test/output2.flv"]
subprocess.call(ffmpeg_command1)
subprocess.call(ffmpeg_command2)
subprocess.Popen(ffmpeg_command3)
But what i really want is to concatenate two strings out1 and out2 and concatinate these two to a file instead of concatenating "/home/xincoz/test/output1.flv" and "/home/xincoz/test/output2.flv". So how can i parse string out1 and out2 as the inputs to mencoder ? Please edit my code to achieve the result.
import subprocess,os
ffmpeg_command = ["ffmpeg", "-i", "/home/xincoz/test/connect.flv", "-acodec", "copy", "-ss", "00:00:00", "-t", "00:00:30","-f", "flv", "pipe:1"]
p = subprocess.Popen(ffmpeg_command,stdout=subprocess.PIPE)
out1, err = p.communicate()
ffmpeg_command1 = ["ffmpeg", "-i", "/home/xincoz/test/connect.flv", "-acodec", "copy", "-ss", "00:00:30", "-t", "00:00:30","-f", "flv", "pipe:1"]
p1 = subprocess.Popen(ffmpeg_command1,stdout=subprocess.PIPE)
out2, err1 = p1.communicate()
ffmpeg_command2 = ["mencoder", "-forceidx", "-ovc", "copy", "-oac", "pcm", "-o", "/home/xincoz/test/final.flv", out1, out2 ]
p2=subprocess.Popen(ffmpeg_command2)
Please help me. Thanks a lot in advance.