How to merge two video parts and get a playable video file using Python?
Question: Here, I actually wants to merge two strings out1 & out2 (which contains the
first and second 30sec long video data) and write that to a file. So that I
will get a 1min long playable video file. But what I am getting is the first
30sec video only. How should I edit this code to achieve that ? Please help
me. Thanks a lot in advance.

    
    
    import subprocess,os
    
    ffmpeg_command1 = ["ffmpeg", "-i", "PATH/connect.webm", "-vcodec", "copy", "-ss", "00:00:00", "-t", "00:00:30","-f", "webm", "pipe:1"]
    
    p1 = subprocess.Popen(ffmpeg_command1,stdout=subprocess.PIPE)
    
    out1, err = p1.communicate()
    
    ffmpeg_command2 = ["ffmpeg", "-i", "PATH/connect.webm","-vcodec", "copy", "-ss", "00:00:31", "-t", "00:00:30","-f", "webm", "pipe:1"]
    
    p2 = subprocess.Popen(ffmpeg_command2,stdout=subprocess.PIPE)
    
    out2, err1 = p2.communicate()
    
    string = out1 + out2
    
    fname = "PATH/final.webm"
    
    fp = open(fname,'wb')
    
    fp.write(string)
    
    fp.close()
    

Please help me. I struck.


Answer: If you want to concat two videos with ffmpeg, it works like that:

    
    
    ffmpeg -vcodec copy -isync -i \
    "concat:file1.mp4|file2.mp4|...|fileN.mp4" \
    outputfile.mp4
    

