NodeJS FFMPEG : Issues combining the crops and the trims

13 Views Asked by At

I'm building a video editor where I can trim multiple clips and adjust the videos by cropping each clip. For example the first clip is centered in the middle and the second clip would be centered at the very right (for more details it's to crop a vertical format from a landscape video). And the goal is obviously to merge every clip in the end into one video.

I currently use this to trim and crop.:

// Constructing the filter string dynamically based on trim times
            const filterString = metadata.trim_times.map(({ start, end }) => `between(t,${start},${end})`).join('+');

            // FFMPEG command to trim the video based on the dynamic filter string
            await ffmpeg.current?.run(
                '-i', 'input.mp4',
                '-vf', `select='${filterString}',setpts=N/FRAME_RATE/TB,crop=(ih*9)/16:ih:${sliderValue}-((ih*9)/32):(in_h-out_h)/2`,
                '-af', `aselect='${filterString}',asetpts=N/SR/TB`,
                'output.mp4'
            );

An idea I had was to loop my filterString const and trim/crop but then to concat i don't really know if that exists :/

I'd love to have some help with that, and please ask me if you need more details on the code Thanks in advance !

0

There are 0 best solutions below