Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To use ffmpeg-static to cut and combine audio and video files that experience freezing at the start of the video, you can follow these steps:

  1. Install ffmpeg-static by running the following command in your terminal:
npm install ffmpeg-static
  1. Create a JavaScript file and import the ffmpeg-static library:
const ffmpegPath = require('ffmpeg-static').path;
const ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath(ffmpegPath);
  1. Use the ffmpeg object to cut and combine the audio and video files. For example, to cut a video from a specific start time and combine it with an audio file, you can use the following code:
ffmpeg()
  .input('video.mp4')
  .setStartTime('00:00:10') // start time of the video
  .input('audio.mp3')
  .output('output.mp4')
  .run();
  1. You can also use the noaccurate_seek option to skip the initial freezing of the video:
ffmpeg()
  .input('video.mp4')
  .inputOptions('-noaccurate_seek')
  .setStartTime('00:00:10') // start time of the video
  .input('audio.mp3')
  .output('output.mp4')
  .run();
  1. Adjust the start time and other options based on your specific needs.

Note: Depending on the size and complexity of your files, the process may take some time to complete.