我正在尝试使用以下命令创建幻灯片。
这是我执行的命令:
ffmpeg
-loop 1 -t 1 -i /sdcard/input0.png
-loop 1 -t 1 -i /sdcard/input1.png
-loop 1 -t 1 -i /sdcard/input2.png
-loop 1 -t 1 -i /sdcard/input3.png
-loop 1 -t 1 -i /sdcard/input4.png
-filter_complex
"[0:v]trim=duration=15,fade=t=out:st=14.5:d=0.5[v0];
[1:v]trim=duration=15,fade=t=in:st=0:d=0.5,fade=t=out:st=14.5:d=0.5[v1];
[2:v]trim=duration=15,fade=t=in:st=0:d=0.5,fade=t=out:st=14.5:d=0.5[v2];
[3:v]trim=duration=15,fade=t=in:st=0:d=0.5,fade=t=out:st=14.5:d=0.5[v3];
[4:v]trim=duration=15,fade=t=in:st=0:d=0.5,fade=t=out:st=14.5:d=0.5[v4];
[v0][v1][v2][v3][v4]concat=n=5:v=1:a=0,format=yuv420p[v]" -map "[v]" /sdcard/out.mp4
执行此命令时会出现如下错误:
onFailure: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[mjpeg @ 0x4362af10] Changing bps to 8
Input #0, image2, from '/sdcard/img0001.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 2410 kb/s
Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 259x194 [SAR 1:1 DAR 259:194], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mjpeg @ 0x436300a0] Changing bps to 8
Input #1, image2, from '/sdcard/img0002.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 2053 kb/s
Stream #1:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 290x174 [SAR 1:1 DAR 5:3], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mjpeg @ 0x436383a0] Changing bps to 8
Input #2, image2, from '/sdcard/img0003.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 3791 kb/s
Stream #2:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 300x168 [SAR 1:1 DAR 25:14], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mjpeg @ 0x43648f50] Changing bps to 8
Input #3, image2, from '/sdcard/img0004.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 1796 kb/s
Stream #3:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 259x194 [SAR 1:1 DAR 259:194], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mjpeg @ 0x437b4070] Changing bps to 8
Input #4, image2, from '/sdcard/img0005.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 1083 kb/s
Stream #4:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 212x160 [SAR 1:1 DAR 53:40], 25 fps, 25 tbr, 25 tbn, 25 tbc
[AVFilterGraph @ 0x4393c960] No such filter: '"'
Error initializing complex filters.
Invalid argument
答案 0 :(得分:0)
它适用于Node.JS,但它可以在任何地方使用。
var exec = require('child_process');
const execFFMpeg = function() {
console.log('... ffmpeg executing');
const process = exec.execFile(
'ffmpeg',
[
"-loop", "1", "-t", "2", "-i", "./images/0036d185-9d8c-4636-87b4-d3633c072ca1_original_Britain-Weather-38.jpg",
"-loop", "1", "-t", "2", "-i", "./images/0024882d-4cb9-4722-a0a2-7efaf7ca67eb_original_Pelicans_Bucks_Basketball_59.jpg",
"-loop", "1", "-t", "2", "-i", "./images/005a7a78-1f16-441a-b045-13f5d8a6fa1c_original_Houston_Rodeo_67.jpg",
"-loop", "1", "-t", "2", "-i", "./images/00631475-78db-424c-bea1-8bc190300e51_original_Britain_Northern_Lights_8.jpg",
"-loop", "1", "-t", "2", "-i", "./images/00bab729-43eb-4cd9-b2c8-e23867e3dbc6_original_Golf_Course_Plane_Crash_79.jpg",
"-filter_complex",
"[1:v][0:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b1v];[2:v][1:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b2v];[3:v][2:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b3v];[4:v][3:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b4v];[0:v][b1v][1:v][b2v][2:v][b3v][3:v][b4v][4:v]concat=n=9:v=1:a=0,format=yuv420p[v]",
"-map", "[v]", "1ddba2f2-1e8e-11e7-b451-069f7b36a73b_original_generated-showcase-video.mp4"
],
{
cwd: './image-rendition'
},
function(err, stdout, stderr) {
console.log('... ffmpeg is compeled:');
}
);
process.stdout.on('data', console.log);
process.stderr.on('data', console.error);
};
execFFMpeg();
请删除filter_complex规则之间的任何空格。
感谢。