Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#8823 closed defect (fixed)

vf_xfade interaction with other filters makes it stop early

Reported by: Stefan-Gabriel Muscalu Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: xfade
Cc: stefan.gabriel.muscalu@gmail.com Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

xfade stops second stream early when certain filters are applied to the second stream.

Version:

ffmpeg version 4.3.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100

How to reproduce:

The following command will work as expected and will output a 9.5s video

ffmpeg -f lavfi -i testsrc=r=25:d=5 -f lavfi -i testsrc=r=60:d=5 -filter_complex "
	[1:v] setpts=PTS-STARTPTS,settb=AVTB [v1];
	[0:v] setpts=PTS-STARTPTS,settb=AVTB [v0];
	[v0][v1] xfade=duration=0.5:transition=wipeleft:offset=4.5
" test.mp4

The following command will output only a 5s video;

ffmpeg -f lavfi -i testsrc=r=25:d=5 -f lavfi -i testsrc=r=60:d=5 -filter_complex "
	[1:v] setpts=PTS-STARTPTS,settb=AVTB,hue=90 [v1];
	[0:v] setpts=PTS-STARTPTS,settb=AVTB [v0];
	[v0][v1] xfade=duration=0.5:transition=wipeleft:offset=4.5
" test.mp4 -y

Please note that the only difference is the addition of the hue filter

Change History (5)

comment:1 by Stefan-Gabriel Muscalu, 4 years ago

After some more testing, the following command works as expected:

ffmpeg -f lavfi -i testsrc=r=25:d=5 -f lavfi -i testsrc=r=60:d=5 -filter_complex "
	[0:v] setpts=PTS-STARTPTS,settb=AVTB [v0];
	[1:v] setpts=PTS-STARTPTS,settb=AVTB,hue=90 [v1];
	[v0][v1] xfade=duration=0.5:transition=wipeleft:offset=4.5
" test.mp4 -y

The difference between this command and the original post non-working one is that i've re-ordered the filter-graph steps to keep the input order.

It appears that once the order of the steps are not the same as the order of the input of xfade, it breaks again:

ffmpeg -f lavfi -i testsrc=r=25:d=5 -f lavfi -i testsrc=r=60:d=5 -filter_complex "
	[0:v] setpts=PTS-STARTPTS,settb=AVTB,hue=90 [v0];
	[1:v] setpts=PTS-STARTPTS,settb=AVTB [v1];
	[v1][v0] xfade=duration=0.5:transition=wipeleft:offset=4.5
" test.mp4 -y

In this example, i've re-ordered xfade to take stream 1 then stream 0, but processed stream 0 first in the graph, then stream 1

comment:2 by Stefan-Gabriel Muscalu, 4 years ago

Cc: stefan.gabriel.muscalu@gmail.com added

comment:3 by Stefan-Gabriel Muscalu, 4 years ago

I'll cross-post this here too, as after this comment ticket:8824#comment:3 clarified that both inputs have to have the same FPS as well as same TB, this example still reproduces the above issue even with both inputs at 60fps:

ffmpeg -f lavfi -i testsrc=r=60:d=5 -f lavfi -i testsrc=r=60:d=5 -filter_complex "
	[1:v] setpts=PTS-STARTPTS,settb=AVTB,hue=90 [v1];
	[0:v] setpts=PTS-STARTPTS,settb=AVTB [v0];
	[v0][v1] xfade=duration=0.5:transition=wipeleft:offset=4.5
" test.mp4 -y

comment:4 by Elon Musk, 4 years ago

Resolution: fixed
Status: newclosed

comment:5 by Carl Eugen Hoyos, 4 years ago

Keywords: xfade added
Note: See TracTickets for help on using tickets.