0

I am trying to concatenate files with named pipes in node js using child process and ffmpeg. I tried to give the text input in this format:

file 'pipe:3'
file 'pipe:4'

But this doesn't work as 'pipe' is not in the whitelist Then I added 'pipe' to the protocol-whitelist. This doesn't help either, and the console outputs a bunch of gibberish. What should I do now? This is my current spawn command.

const command = spawn('ffmpeg', ['-f', 'concat', '-safe', '0', '-protocol_whitelist', 'file,pipe', '-i', 'data/' + mergedVideoName + '.txt', '-c', 'copy', '-f', 'ismv', 'pipe:1'], {
        stdio: pipes
    })

Here, pipes are just the array with the required number of 'pipe' strings. I wanted to pass some streams via pipe method to the input directly instead of using the file system,.

Edit: I tried this again and now the stderr output is not gibberish, but I still can't get it to work. Here is the code for the file: https://pastebin.com/1GgCWGWk

I am able to get the first video as output, but not the next videos. As for the log from stderr, I mainly get this as the error:

[ismv @ 0000021c2ce14840] Non-monotonous DTS in output stream 0:0; previous: 273834031, current: 159533333; changing to 273834032. This may result in incorrect timestamps in the output file.

I also get this error:

[ismv @ 0000021c2ce14840] Track 0 starts with a nonzero dts 333333, while the moov already has been written. Set the delay_moov flag to handle this case.

And this error right at the end:

data: [concat @ 000001b4bebf5c00] Impossible to open 'pipe:5'
data/4ed57360-d5f8-11ec-b35f-7b4d7aa196cd.mp4.txt: Invalid data found when processing input

How do I solve these problems?

  • Post the ffmpeg log (capture process 'stderr') – kesh May 17 '22 at 13:32
  • I added more information to the original post... can you see if that is helpful? @kesh – ironmuscle002 May 17 '22 at 16:00
  • The "Non-monotonous DTS in output stream" error/warning is an almost-for-sure indication of `concat` demuxer incompatible input sources. You need to make sure that the framerate and timebase (both format & stream) are the same among all the files listed in the ffconcat file. Otherwise, you're sol unfortunately. – kesh May 17 '22 at 16:09
  • @kesh I have applied this command in my code on all of the inputs before trying to concatenate. const cmd1 = spawn('ffmpeg', ['-i', 'pipe:0', '-acodec', 'aac', '-vcodec', 'libx264', '-s', '1920x1080', '-r', '60', '-video_track_timescale', '90000', '-f', 'ismv', 'pipe:1'] Is there anything I'm missing? – ironmuscle002 May 17 '22 at 16:59
  • Looks good... Hmmm, have you tried to use different container for these input streams? (even raw .h264 format if you have the total control over the video format). Also, any chance of dropped frames among input streams? (another thing that wrecks havoc on concat operation) – kesh May 18 '22 at 03:06

0 Answers0