kkroening / ffmpeg-python

Python bindings for FFmpeg - with complex filtering support
Apache License 2.0
9.8k stars 880 forks source link

Videos concat not work #836

Open tungmt opened 4 months ago

tungmt commented 4 months ago

I try to concat 2 videos but I was got an error.

Here is my code:

    try:
        in1 = ffmpeg.input(args.videos[0])
        in2 = ffmpeg.input(args.videos[1])
        v1 = in1.video
        a1 = in1.audio
        v2 = in2.video
        a2 = in2.audio
        joined = ffmpeg.concat(v1, a1, v2, a2, n=2, v=1, a=1).node
        out = (
            ffmpeg.output(joined[0], joined[1], 'out.mov')
            .overwrite_output()
            .run()
        )
        print(out)
    except ffmpeg.Error as e:
        print(e.stderr, file=sys.stderr)
        sys.exit(1)

Here is error I got:

[fc#0 @ 0x600003099a70] Stream specifier ':a' in filtergraph description [0:v][0:a][1:v][1:a]concat=a=1:n=2:v=1[s0][s1] matches no streams.
Error binding filtergraph inputs/outputs: Invalid argument
AdrKacz commented 4 months ago

Did you try to run

(
    ffmpeg
    .concat(
        ffmpeg.input(args.videos[0]),
        ffmpeg.input(args.videos[1])
    )
    .output('out.mov') # Unless your input are already .mov you'll probably have to do some conversion here
    .run()
)

I am not sure I understand exactly what you are trying to achieve. Can you give more details please?