0

I am trying to understand the how FFmpeg's filtergraph works with the help of the graph2dot utility (FFmpeg graph2dot tool).

I am using an example from one of the questions previously posted here (How to concatenate clips from the same video with ffmpeg). Upon trying to parse the following filtergraph which is adapted from the accepted answer,

echo "nullsrc[vid];anullsrc[aud];[vid]trim=60:65,setpts=PTS-STARTPTS[v0];[aud]atrim=60:65,asetpts=PTS-STARTPTS[a0];[vid]trim=120:125,setpts=PTS-STARTPTS[v1];[aud]atrim=120:125,asetpts=PTS-STARTPTS[a1];[v0][a0][v1][a1]concat=n=2:v=1:a=1[out];[out]nullsink" | graph2dot

I get the following error with FFmpeg (ver 3.4):

[Parsed_nullsrc_0 @ 0x55cd2c952240] size:320x240 rate:25/1 duration:-1.000000 sar:1/1
[Parsed_trim_2 @ 0x55cd2c953500] Setting 'start' to value '60'
[Parsed_trim_2 @ 0x55cd2c953500] Setting 'end' to value '65'
[Parsed_setpts_3 @ 0x55cd2c953fc0] Setting 'expr' to value 'PTS-STARTPTS'
[Parsed_atrim_4 @ 0x55cd2c954f20] Setting 'start' to value '60'
[Parsed_atrim_4 @ 0x55cd2c954f20] Setting 'end' to value '65'
[Parsed_asetpts_5 @ 0x55cd2c955960] Setting 'expr' to value 'PTS-STARTPTS'
[Parsed_trim_6 @ 0x55cd2c9568c0] Setting 'start' to value '120'
[Parsed_trim_6 @ 0x55cd2c9568c0] Setting 'end' to value '125'
[Parsed_setpts_7 @ 0x55cd2c957120] Setting 'expr' to value 'PTS-STARTPTS'
[Parsed_atrim_8 @ 0x55cd2c957fa0] Setting 'start' to value '120'
[Parsed_atrim_8 @ 0x55cd2c957fa0] Setting 'end' to value '125'
[Parsed_asetpts_9 @ 0x55cd2c9587a0] Setting 'expr' to value 'PTS-STARTPTS'
[Parsed_concat_10 @ 0x55cd2c9596c0] Setting 'n' to value '2'
[Parsed_concat_10 @ 0x55cd2c9596c0] Setting 'v' to value '1'
[Parsed_concat_10 @ 0x55cd2c9596c0] Setting 'a' to value '1'
Input pad "default" with type video of the filter instance "Parsed_trim_6" of trim not connected to any source

As far as I understand, the "Parsed_trim_6" filter is connected to the source nullsrc[vid].

Can anyone help me understand what's wrong here and how I can fix it?

EDIT: Following Mulvya's hints, the correct solution is given below:

echo "nullsrc,split=2[vid1][vid2];anullsrc,asplit=2[aud1][aud2];[vid1]trim=60:65,setpts=PTS-STARTPTS[v0];[aud1]atrim=60:65,asetpts=PTS-STARTPTS[a0];[vid2]trim=120:125,setpts=PTS-STARTPTS[v1];[aud2]atrim=120:125,asetpts=PTS-STARTPTS[a1];[v0][a0][v1][a1]concat=n=2:v=1:a=1[outv][outa];[outv]nullsink,[outa]anullsink" | graph2dot

Other lessons I learnt from this

  • Video and audio streams require separate sinks. Even with the concat filter, I wasn't able to merge them into the [out] destination as I had originally done
2

You can consume a filter generated stream only once, unlike streams from -i inputs. Since [vid] is already supplied to the first trim 60:65, it can't be reused. You can add a split and supply a copy to each:

nullsrc,split=2[vid1][vid2]; ... [vid1]trim=60:65, ... [vid2]trim=120:125, ...
  • Thanks. It wasn't clear from the documentation that nullsink could be used only once. I have added the complete solution to the question. – Imad Nov 10 '17 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.