ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

Videos concat not work

Open tungmt opened this issue 1 year ago • 2 comments

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

tungmt avatar Apr 16 '24 12:04 tungmt

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?

AdrKacz avatar Apr 25 '24 09:04 AdrKacz

@tungmt you can use videoalchemy to have readable yaml base ffmpeg command. when it success get generated ffmpeg command and use that in your code.

hsngerami avatar Sep 08 '24 11:09 hsngerami