You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asyncfunctionextractClipsWithComplexFilter(id,jsonClips,localMP4File){conststartTime=Date.now();leti=0;letcomplexFilterArray=[];for(constclipofjsonClips.clips){console.log(`Extracting clip_${i}`);complexFilterArray.push(`[0:v]trim=start=${utils.parseTime(clip.startTimestamp)/1000}:end=${utils.parseTime(clip.endTimestamp)/1000},setpts=PTS-STARTPTS[v_clip_${i}]`);complexFilterArray.push(`[0:a]atrim=start=${utils.parseTime(clip.startTimestamp)/1000}:end=${utils.parseTime(clip.endTimestamp)/1000},asetpts=PTS-STARTPTS[a_clip_${i++}]`);break;// only do one clip for now}letmapArray=[];letoutputArray=[];for(letj=0;j<i;j++){mapArray.push(`-map '[v_clip_${j}]' -map '[a_clip_${j}]'`);outputArray.push(`clip_${j}.mp4`);}/* This CLI works ffmpeg -i test.mp4 -filter_complex [0:v]trim=start=1948.605:end=2038.755,setpts=PTS-STARTPTS[v_clip_0]; [0:a]atrim=start=1948.605:end=2038.755,asetpts=PTS-STARTPTS[a_clip_0]; ... [0:v]trim=start=5041.255:end=5131.045,setpts=PTS-STARTPTS[v_clip_10]; [0:a]atrim=start=5041.255:end=5131.045,asetpts=PTS-STARTPTS[a_clip_10]; -map '[v_clip_0]' -map '[a_clip_0]' clip_0.mp4 ... -map '[v_clip_10]' -map '[a_clip_10]' clip_10.mp4 */ffmpeg(localMP4File).complexFilter(complexFilterArray).output('clip_0.mp4').map('[v_clip_0]').map('[a_clip_0]').on('error',error=>console.log('Error: '+error.message)).on('end',()=>console.log('Success!')).run();console.log(`Extracted ${complexFilterArray.length} clips in ${Date.now()-startTime}`);return{status: 200}// TODO: failure}
(note: if the problem only happens with some inputs, include a link to such an input file)
Expected results
I pass a json array of clip information with start and end timestamps. The number of clips could vary from 1-50.
What I want is a way to define an array of outputs and maps at runtime and create a number of clips.
Observed results
A single clip works as above. The ffmpeg command works for multiple clips as above. I've had various attempts to pass arrays to output and map without success.
Checklist
The text was updated successfully, but these errors were encountered:
Version information
Code to reproduce
(note: if the problem only happens with some inputs, include a link to such an input file)
Expected results
I pass a json array of clip information with start and end timestamps. The number of clips could vary from 1-50.
What I want is a way to define an array of outputs and maps at runtime and create a number of clips.
Observed results
A single clip works as above. The ffmpeg command works for multiple clips as above. I've had various attempts to pass arrays to output and map without success.
Checklist
The text was updated successfully, but these errors were encountered: