Concatenation of multiple video files in single file

Grant Edwards grant.b.edwards at gmail.com
Sat May 9 21:37:39 EDT 2020


On 2020-05-09, Chris Angelico <rosuav at gmail.com> wrote:
> On Sun, May 10, 2020 at 8:50 AM Akshay Ghodake <justrock.akki at gmail.com> wrote:
>
>> I want a help to concatenation of multiple video files into a single file
>> in python.
>>
>> Any help will be greatly appreciated.
>
> Step 1:
> import subprocess
>
> Step 2:
> Run ffmpeg

Definitely.

Mencoder does a nice job with some containers (particularly AVI), but
ffmpeg is probably more actively maintained and more widely applicable.

If you would rather spend weeks instead of minutes, you could try
using Python ffmpeg bindings:

    https://github.com/kkroening/ffmpeg-python

That will take a lot longer to develop and work and won't as well.

If you would rather spend years instead of weeks, you start with this:

    import sys
    infile = open(sys.argv[1],'rb')
    outfile = open(sys.argv[2],'wb')
    print("Converting %s to %s" % (sys.argv[1],sys.argv[2]))
    # some stuff goes here
    infile.close()
    outfile.close()

Then you study the specifications for the container formats you want
to support, the audio and video codecs you want to support, and fill
in 'some stuff'.  This will take, much, much longer to develop and
mostly just won't work, period.  You will learn a lot more, though. :)

--
Grant



More information about the Python-list mailing list