AlexZheda
AlexZheda

Reputation: 475

ffmpeg read from a file and apply filter_complex at once

I am feeding fls.txt into ffmpeg -i and applying concat and a speedup.

fls.txt

file 'input1.mp4'
file 'input2.mp4'
file 'input3.mp4'

The command in one go looks as follows:

ffmpeg  -i fls.txt     \
-filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a] concat=n=3:v=1:a=1 [v][a];\
[v]setpts=0.5*PTS[v1];[a]atempo=2,asetpts=N/SR/TB[a1]"     \
-c:v h264_nvenc -map "[v1]" -map "[a1]"  x2.mp4

The output is really weird and says something like a stream is not found. And it also looks like as if it's trying to understand the fls.txt itself and not its content as the parameters. What am I doing wrong here and how can I correct it? Also, it's a simplified example and I cannot write per hand 3 input file paths. I need it to be read from a file. I'm on windows 10 if that matters.

EDIT: From doing the suggested edits and expanding the -filter_complex I get an error below.

ffmpeg -f concat -safe 0 -i fls.txt     \
-filter_complex "[0:v]setpts=0.5*PTS[v1];[v1]setpts=0.5*PTS[v2];[0:a]atempo=2,asetpts=N/SR/TB[a1];[a1]atempo=2,asetpts=N/SR/TB[a2]"     \
-c:v h264_nvenc -map "[v1]" -map "[a1]" x2.mp4 \
-c:v h264_nvenc -map "[v2]" -map "[a2]" x4.mp4

error:

Output with label 'v1' does not exist in any defined filter graph, or was already used elsewhere.

Upvotes: 3

Views: 1757

Answers (1)

llogan
llogan

Reputation: 133793

Stream specifier ':a' in filtergraph description … matches no streams.

To enable the concat demuxer you have to use -f concat before -i fls.txt.

ffmpeg -f concat -i fls.txt     \
-filter_complex "[0:v]setpts=0.5*PTS[v1];[0:a]atempo=2,asetpts=N/SR/TB[a1]"     \
-c:v h264_nvenc -map "[v1]" -map "[a1]" x2.mp4

Because you're attempting to use the concat demuxer there is no need for the concat filter as well, so you can simplify the command.

You may also have to use -safe 0 before -i which you can read about in the documentation.

Follow-up question: Output with label 'v1' does not exist in any defined filter graph, or was already used elsewhere

You can't reuse consumed filter output labels so this example avoids that:

ffmpeg -f concat -safe 0 -i fls.txt     \
-filter_complex "[0:v]setpts=0.5*PTS[2xv];[0:v]setpts=PTS/4[4xv];[0:a]atempo=2,asetpts=N/SR/TB[2xa];[0:a]atempo=4,asetpts=N/SR/TB[4xa]"     \
-c:v h264_nvenc -map "[2xv]" -map "[2xa]" x2.mp4 \
-c:v h264_nvenc -map "[4xv]" -map "[4xa]" x4.mp4

Upvotes: 1

Related Questions