fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.63k stars 873 forks source link

转码错误: ffmpeg was killed with signal SIGSEGV #1204

Open nicky132 opened 1 year ago

nicky132 commented 1 year ago

Version information

Code to reproduce

ffmpeg -rtsp_transport tcp -buffer_size 102400 -i rtsp://[account]:[password]@[ip]:[port]/Streaming/Channels/101
 -an -vcodec libx264 -filter:v scale=w=trunc(iw*1/2)*2:h=trunc(ih*1/2)*2 -threads 4 -tune zerolatency -preset ultrafast -f flv pipe:1 

image

image

(note: if the problem only happens with some inputs, include a link to such an input file)

Expected results

works correctly

Observed results

ffmpeg was killed with signal SIGSEGV by the way,this code i run it on windows desktop,very well,but it can not work on centos with pm2 start index.js, which i do not know why

Checklist

alanbacon commented 1 year ago

yes this is happening to me as well with the following command:

ffmpeg -sseof -20 -i ./input000.mp3 -i ./input001.mp3 -y -filter_complex '[0:0][1:0]concat=n=2:v=0:a=1[out]' -map '[out]' ./overlapping/output001.mp3

which i get by using the following code

export function createOverlappingFileFromPreviousInput(
  previousInputFilename: string,
  currentInputFilename: string,
  outputFilename: string,
  secondsToOverlap: number = 20
): void {
  FfmpegCommand(previousInputFilename)
    .inputOptions("-sseof", (-1 * secondsToOverlap).toString())
    .input(currentInputFilename)
    .outputOptions(
      "-filter_complex",
      "'[0:0][1:0]concat=n=2:v=0:a=1[out]'",
      "-map",
      "'[out]'"
    )
    .on("start", console.log)
    .output(outputFilename)
    .run();
}

createOverlappingFileFromPreviousInput(
  "./input000.mp3",
  "./input001.mp3",
  "./overlapping/output001.mp3"
);

The command works when entering directly into the command line shell, but not when using fluent-ffmpeg, the error shown is:

ffmpeg -sseof -20 -i ./input000.mp3 -i ./input001.mp3 -filter_complex '[0:0][1:0]concat=n=2:v=0:a=1[out]' -map '[out]' ./overlapping/output001.mp3
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: ffmpeg was killed with signal SIGSEGV
    at ChildProcess.<anonymous> (<project>/node_modules/fluent-ffmpeg/lib/processor.js:180:22)
    at ChildProcess.emit (node:events:513:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
Emitted 'error' event on FfmpegCommand instance at:
    at emitEnd (<project>/node_modules/fluent-ffmpeg/lib/processor.js:424:16)
    at endCB (<project>/node_modules/fluent-ffmpeg/lib/processor.js:544:13)
    at handleExit (<project>/node_modules/fluent-ffmpeg/lib/processor.js:170:11)
    at ChildProcess.<anonymous> (<project>/node_modules/fluent-ffmpeg/lib/processor.js:180:11)
    at ChildProcess.emit (node:events:513:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
LefanTan commented 10 months ago

@alanbacon did you ever manage to fix this? I ran into the same issue

alanbacon commented 10 months ago

Sorry no, in the end I stopped using the library and passed the ffmpeg commands directly to a command process :-(

jontybrook commented 6 months ago

I just came across this... downgrading the node version i'm using from 20 to 18 seems to have worked.

jontybrook commented 6 months ago

Update... seems in my case this was related to the base image i'm using for my docker build.

If trying to use the newer node:18-bookworm base image, I get these SIGSEGV errors.

However, using node:18-buster base image I do not.

So.. I suspect this is something to do with changes in newer debian versions. Either way, i'm OK using buster!

partnerjun commented 4 months ago

In my case(My Application deployed on AWS beanstalk Node 18+), I solved this problem by not using the URL(and URL readStream) to the path parameter. Instead, I downloaded the file and passed the file path directly.

like below.

/* before */
ffmpeg('https://example.com') // killed with "SIGSEGV"

/* after */
// download video file
const filePath = path.join(process.env.INIT_CWD, 'tmp', 'example.mp4')
await download('https://example.com', filePath) // https://stackoverflow.com/a/22907134

// call fluent-ffmpeg
try {
  ffmpeg(filePath) // blah blah
} finally {
  fs.unlinkSync(filePath)
}

I think there may have been changes to the https or net packages in the node environment. If someone has a similar experience, please share user case.

aqibhassanzeb commented 2 months ago

I'm also facing this issue it's working on local system perfectly,but when i'm running on EC2 instance then getting error like that : Error: ffmpeg was killed with signal SIGSEGV

This is my code :

let dateString = uuidv4(); const outputVideo = "./outputs/" + dateString + "-video.mp4"; ffmpeg() .input(mainVidUrl) .input(overlayVideo) .input(selectedTv == 'one' ? selectedTv1 : selectedTv2) .complexFilter(selectedTv == 'one' ? complexFilterOption1 : complexFilterOption2) .output(outputVideo) .on('progress', onProgress) .on('end', () => { console.log('Processing finished!'); some logic ... }) .on('error', (err: any) => { console.error('Error:', err); }) .run();

versions : ffmpeg version 4.4.2-0ubuntu0.22.04.1

Any solution for that?