在这里,我尝试将第一个和第二个 30 秒长的视频文件从“path/connect.webm”剪切到字符串 out 和 out1。有用。但我需要做的是连接这两个字符串并将其写入文件“path/final.webm”。这样我最后就会得到一个 60 秒长的视频文件“final.webm”。但现在我只得到第一个 30 秒长的视频作为输出。请帮我。提前非常感谢。
python中的代码:
import subprocess,os
fname = "/home/xincoz/test/final.webm"
fp = open(fname,'wb')
ffmpeg_command = ["ffmpeg", "-i", "/home/xincoz/test/connect.webm", "-acodec", "copy", "-ss", "00:00:00", "-t", "00:00:30","-f", "webm", "pipe:1"]
p = subprocess.Popen(ffmpeg_command,stdout=subprocess.PIPE)
out, err = p.communicate()
ffmpeg_command1 = ["ffmpeg", "-i", "/home/xincoz/test/connect.webm", "-acodec", "copy", "-ss", "00:00:31", "-t", "00:00:30","-f", "webm", "pipe:1"]
p1 = subprocess.Popen(ffmpeg_command1,stdout=subprocess.PIPE)
out1, err1 = p1.communicate()
string = out + out1
print len(out)
print len(out1)
print len(string)
fp.write(string)
fp.close()
请帮我。