Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 最后一个子进程调用在带有FFMPEG的级联代码中不起作用。我该如何着手解决这个问题?_Python_Ffmpeg_Concatenation_Mp4 - Fatal编程技术网

Python 最后一个子进程调用在带有FFMPEG的级联代码中不起作用。我该如何着手解决这个问题?

Python 最后一个子进程调用在带有FFMPEG的级联代码中不起作用。我该如何着手解决这个问题?,python,ffmpeg,concatenation,mp4,Python,Ffmpeg,Concatenation,Mp4,我正在尝试创建剪辑连接器,但最后一个子进程调用将不会运行,并且不会给我任何错误。当我运行脚本时,第一个FFmpeg调用工作正常,并提供我的中间mp4文件,但是,当我在终端中运行它时,第二个命令工作,当我使用subprocess.call从python运行它时,它不工作 问题代码: clips = [] #generates a list of mp4 files in a folder def clipFinder(CurrentDir, fileType): clips.clear(

我正在尝试创建剪辑连接器,但最后一个子进程调用将不会运行,并且不会给我任何错误。当我运行脚本时,第一个FFmpeg调用工作正常,并提供我的中间mp4文件,但是,当我在终端中运行它时,第二个命令工作,当我使用subprocess.call从python运行它时,它不工作

问题代码:

clips = []

#generates a list of mp4 files in a folder
def clipFinder(CurrentDir, fileType):
    clips.clear()
    for r,d,f in os.walk(CurrentDir):
        for file in f:
            if fileType in file:
                clips.append(r+file)
    random.shuffle(clips)

#removes all files that have the string 'vod' in them as they cause problems during concatenation
def removeVods(r):
    for f in clips:
        if 'vod' in clips:
            os.remove(r+f)

#generates a string using the clips list to insert into the ffmpeg command
def clipString():
    string = 'intermediate'
    clipList = []
    clipNum = 1
    for f in clips:
        clipList.append(string+str(clipNum)+'.ts'+'|')
        clipNum+=1
    string1 = ''.join(clipList)
    string2 = string1[0:len(string1)-1]
    return string2

#concatenates the mp4 files in the clipString
def concatFiles():
    clipFinder('***', '.mp4')
    removeVods('***')
    i = 0
    intermediates = []
    for f in clips:
        subprocess.call(['***', '-i', clips[i], '-c', 'copy', '-bsf:v', 'h264_mp4toannexb', '-f', 'mpegts', 'intermediate'+ str(i+1) +'.ts'])
        i += 1 
    clipsLength = len(clips)
    subprocess.call['***', '-i', '"concat:' + clipString() + '"', '-c', 'copy', '-bsf:a 
    aac_adtstoasc', 'output.mp4']
所有带有*的位置都是路径,例如:/davidscomputer/bin/ffmpeg/

问题代码: 子进程。调用['***'、'-i'、'-concat:'+clipString()+''、'-c',copy','-bsf:aac_adtstoasc',output.mp4']

解决方案: commandString=['/Users/teoscomputer/bin/ffmpeg','-i','concat:'+clipString(),'-c','copy','-bsf:a','aac_adtstoasc','output.mp4'] subprocess.Popen(commandString)

有两个问题: 1) “-bsf:a aac_adtstoasc”需要分为“-bsf:a”、“aac_adtstoasc”


2) “concat周围的引号需要删除,因为只有在shell中运行直接命令时才需要它们

”给出了问题中显示的错误。“错在哪里?我没看到。我在我的描述中添加了更多。希望它现在更有意义。我确信我遗漏了一些非常明显的东西。可能是我不懂python的副本,因此我不能就此发表评论,但第二个ffmpeg命令是否真的得到了执行?无论如何,您可以跳过中间文件的创建。只需使用concat解复用器,我喜欢保留中间部分,因为它有助于为第二个FFmpeg生成更简单的字符串。我认为@llogan关于第二个命令没有执行的说法是完全正确的,但我不知道为什么。
subprocess.call(['***', '-i', '"concat:' + clipString() + '"', '-c', 'copy', '-bsf:a aac_adtstoasc', 'output.mp4'])