transitive-bullshit / ffmpeg-gl-transition

FFmpeg filter for applying GLSL transitions between video streams.
650 stars 126 forks source link

[bug] multiple transitions not taking effect in single filter chain #4

Closed drlukacs closed 6 years ago

drlukacs commented 6 years ago

I would like to patch together three segments, and use one type of transition between the first and the second, and another one between the second and the third.

This appears to be impossible. The last "source=" command determines the transition being used for each occurrence of the filter.

EXAMPLE:

ffmpeg \ -i file1.mp4 \ -i file2.mp4 \ -filter_complex " \ [0:v]split=4[v000][v010][v020][v030]; \ [0:a]asplit=2[a000][a020]; \ [v000]trim=27.2:28.55[v001t]; \ [a000]atrim=27.2:28.55[a001t]; \ [v001t]setpts=PTS-STARTPTS[v001]; \ [a001t]asetpts=PTS-STARTPTS[a001]; \ [v010]trim=28.55:29.55[v011t]; \ [v011t]setpts=PTS-STARTPTS[v011]; \ [v020]trim=33:34.35[v021t]; \ [a020]atrim=33:34.35[a021t]; \ [v021t]setpts=PTS-STARTPTS[v021]; \ [a021t]asetpts=PTS-STARTPTS[a021]; \ [v030]trim=34.35:34.75[v031t]; \ [v031t]setpts=PTS-STARTPTS[v031]; \ [1:v]trim=0:8[v100t]; \ [1:a]atrim=0:8[a100t]; \ [v100t]setpts=PTS-STARTPTS[v100]; \ [a100t]asetpts=PTS-STARTPTS[a100]; \
[v011][v021]gltransition=duration=0.15:source=transitions/fade.glsl[vt1]; \ [v031][v100]gltransition=duration=0.35:source=transitions/luma.glsl[vt2]; \ [v001][vt1][vt2]concat=n=3[outv]; \ [a001][a021][a100]concat=n=3:v=0:a=1[outa]" \ -map "[outv]" \ -map "[outa]" \ -y -q:v 1 tmp/out.mp4

This code will result in luma.glsl being applied to both transitions.

transitive-bullshit commented 6 years ago

Great catch! I can reproduce this on my end. Will work on a fix and should be able to get back to you by end of day.

transitive-bullshit commented 6 years ago

I just pushed a commit which should resolve this issue. I tested it successfully locally with three different transitions in a single filter chain.

@drlukacs lemme know if this resolves your issue, and please star this repo to help other people find it :)

drlukacs commented 6 years ago

Thank you @transitive-bullshit for the quick fix. I checked, and it works on my end too.

I starred this repo; however, I would strongly recommend that you propose it for ffmpeg as well. These features should be part of the standard ffmpeg package.