const ffmpeg = require('fluent-ffmpeg');
const command = ffmpeg();
command
.input('1.mp4')
.input('2.mp4')
.input('3.mp4')
.input('4.mp4')
.input('5.mp4')
.input('6.mp4')
.filterGraph([
'[0][1]xfade=transition=hblur:duration=0.5:offset=9.25[V1]',
'[V1][2]xfade=transition=hblur:duration=0.5:offset=13.75[V2]',
'[V2][3]xfade=transition=hblur:duration=0.5:offset=38.25[V3]',
'[V3][4]xfade=transition=hblur:duration=0.5:offset=67.75[V4]',
'[V4][5]xfade=transition=hblur:duration=0.5:offset=107.25,format=yuv420p[video]',
'[0:a][1:a]acrossfade=duration=0.5:c1=tri:c2=tri[A1]',
'[A1][2:a]acrossfade=duration=0.5:c1=tri:c2=tri[A2]',
'[A2][3:a]acrossfade=duration=0.5:c1=tri:c2=tri[A3]',
'[A3][4:a]acrossfade=duration=0.5:c1=tri:c2=tri[A4]',
'[A4][5:a]acrossfade=duration=0.5:c1=tri:c2=tri[audio]'
])
.outputOptions(['-map [video]', '-map [audio]'])
.on('error', (error, stdout, stderr) => {
console.error('concatenateCommand failed');
console.error(error);
console.error(stderr);
})
.on('end', () => {
console.info('concatenateCommand done');
})
.saveToFile('out.mp4');
Should work with all transition options
Works for all except following:
Errors are the same. Here is the output for one of them:
console.log
[ FFMPEG_SERVICE ] 14:57:22.838 WARN ffmpeg exited with code 1: Error initializing complex filters.
Invalid argument
{}
Error: ffmpeg exited with code 1: Error initializing complex filters.
Invalid argument
at ChildProcess.<anonymous> (/Users/acherednichenko/projects/doodlemaker/doodlemaker.renderer/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at ConsoleAppender.write (node_modules/simple-node-logger/lib/ConsoleAppender.js:45:13)
at Array.forEach (<anonymous>)
console.log
[ FFMPEG_SERVICE ] 14:57:22.838 WARN ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 11.0.3 (clang-1103.0.32.62)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
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
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/acherednichenko/projects/doodlemaker/doodlemaker.renderer/lib/capture/__tests__/2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:09.54, start: 0.000000, bitrate: 609 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 52 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 545 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/acherednichenko/projects/doodlemaker/doodlemaker.renderer/lib/capture/__tests__/3.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:11.80, start: 0.000000, bitrate: 484 kb/s
Stream #1:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 66 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #1:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 405 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
[xfade @ 0x7fbc3f437780] [Eval @ 0x7ffeeef1eb90] Undefined constant or missing '(' in 'hblur'
[xfade @ 0x7fbc3f437780] Unable to parse option value "hblur"
[xfade @ 0x7fbc3f437780] [Eval @ 0x7ffeeef1ebe0] Undefined constant or missing '(' in 'hblur'
[xfade @ 0x7fbc3f437780] Unable to parse option value "hblur"
[xfade @ 0x7fbc3f437780] Error setting option transition to value hblur.
[Parsed_xfade_0 @ 0x7fbc3f4376c0] Error applying options to the filter.
[AVFilterGraph @ 0x7fbc3f42ec40] Error initializing filter 'xfade' with args 'transition=hblur:duration=0.5:offset=8.786'
Error initializing complex filters.
Invalid argument
at ConsoleAppender.write (node_modules/simple-node-logger/lib/ConsoleAppender.js:45:13)
at Array.forEach (<anonymous>)
Note: The output above is produced from the integration test which uses some logger lib and etc, but the command setup is the same as in "code to reproduce"
Sorry if I'm posting it here, I'll reference this issue in ffmpeg too.
Even if it is not your problem, I think it is good to know about that for your team too.
The FFmpeg CLI tool also fails but I can't submit a bug on their tracker because I can't register.
Their bug tracker doesn't send a confirmation email.
So I'd be super thankful if somebody in your community can help
Here is the ffmpeg issue tracker card I eventually managed to post:
https://trac.ffmpeg.org/ticket/8934
Please upvote it.
Most helpful comment
Here is the ffmpeg issue tracker card I eventually managed to post:
https://trac.ffmpeg.org/ticket/8934
Please upvote it.