caffco / get-video-duration

Get the duration of a video file
MIT License
138 stars 17 forks source link

Not working on AWS EC2 (Linux) ? #296

Open mxnuchim opened 11 months ago

mxnuchim commented 11 months ago

I'm using your package to get video durationfrom a url that I am fetching from S3 Bucket. On my local computer, its working perfectly, but after releasing to my server on AWS Ec2, the whole app is crashing and I am getting the error below . Just cant understand what`s problem

Does the package not work on Linux?

Error: Command was killed with SIGSEGV (Segmentation fault): /home/ubuntu/Zooto-Backend/node_modules/@ffprobe-installer/linux-x64/ffprobe -v error -show_format -show_streams https://zooto-event-recordings.s3.eu-west-1.amazonaws.com/65031acf9d7df4ff742127bd/2347081601461/be76abfbc443ab37c95c0fa15ef5ff42_65031acf9d7df4ff742127bd_%2B2347081601461_0.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAYOVAHGFKARIGALXN%2F20230919%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20230919T132249Z&X-Amz-Expires=900&X-Amz-Signature=ce200231059b40282b51f158b4cc6ddf6a3b779b339ce2b1a9872955720e042a&X-Amz-SignedHeaders=host&x-id=GetObject 0|zooto-backend | at makeError (/home/ubuntu/Zooto-Backend/node_modules/execa/lib/error.js:60:11) 0|zooto-backend | at handlePromise (/home/ubuntu/Zooto-Backend/node_modules/execa/index.js:118:26) 0|zooto-backend | at runMicrotasks (<anonymous>) 0|zooto-backend | at processTicksAndRejections (node:internal/process/task_queues:96:5) { 0|zooto-backend | shortMessage: 'Command was killed with SIGSEGV (Segmentation fault): /home/ubuntu/Zooto-Backend/node_modules/@ffprobe-installer/linux-x64/ffprobe -v error -show_format -show_streams https://zooto-event-recordings.s3.eu-west-1.amazonaws.com/65031acf9d7df4ff742127bd/2347081601461/be76abfbc443ab37c95c0fa15ef5ff42_65031acf9d7df4ff742127bd_%2B2347081601461_0.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAYOVAHGFKARIGALXN%2F20230919%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20230919T132249Z&X-Amz-Expires=900&X-Amz-Signature=ce200231059b40282b51f158b4cc6ddf6a3b779b339ce2b1a9872955720e042a&X-Amz-SignedHeaders=host&x-id=GetObject', 0|zooto-backend | command: '/home/ubuntu/Zooto-Backend/node_modules/@ffprobe-installer/linux-x64/ffprobe -v error -show_format -show_streams https://zooto-event-recordings.s3.eu-west-1.amazonaws.com/65031acf9d7df4ff742127bd/2347081601461/be76abfbc443ab37c95c0fa15ef5ff42_65031acf9d7df4ff742127bd_%2B2347081601461_0.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAYOVAHGFKARIGALXN%2F20230919%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20230919T132249Z&X-Amz-Expires=900&X-Amz-Signature=ce200231059b40282b51f158b4cc6ddf6a3b779b339ce2b1a9872955720e042a&X-Amz-SignedHeaders=host&x-id=GetObject', 0|zooto-backend | escapedCommand: '"/home/ubuntu/Zooto-Backend/node_modules/@ffprobe-installer/linux-x64/ffprobe" -v error -show_format -show_streams "https://zooto-event-recordings.s3.eu-west-1.amazonaws.com/65031acf9d7df4ff742127bd/2347081601461/be76abfbc443ab37c95c0fa15ef5ff42_65031acf9d7df4ff742127bd_%2B2347081601461_0.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAYOVAHGFKARIGALXN%2F20230919%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20230919T132249Z&X-Amz-Expires=900&X-Amz-Signature=ce200231059b40282b51f158b4cc6ddf6a3b779b339ce2b1a9872955720e042a&X-Amz-SignedHeaders=host&x-id=GetObject"', 0|zooto-backend | exitCode: undefined, 0|zooto-backend | signal: 'SIGSEGV', 0|zooto-backend | signalDescription: 'Segmentation fault', 0|zooto-backend | stdout: '', 0|zooto-backend | stderr: '', 0|zooto-backend | failed: true, 0|zooto-backend | timedOut: false, 0|zooto-backend | isCanceled: false, 0|zooto-backend | killed: false 0|zooto-backend | }

mxnuchim commented 11 months ago

Hello?

milesyang0220 commented 11 months ago

@mxnuchim, we are facing the same problem. Our original setup was working with Amazon Linux 2 + xx64 + node.js 16. After we upgraded to Amazon Linux 2023 + ARM + Node.js 18, we encountered issues. and we try using al2023 + x86_64 + node.js 18, issues still occured, I think changed to Amazon Linux 2 was a workaround solution. Please note that this is a workaround solution. hope this can help u.

atumas-bananamilk commented 10 months ago

Same problem after deploying to Vercel: Error: Could not find ffprobe executable, tried "/var/task/node_modules/get-video-duration/node_modules/@ffprobe-installer/linux-x64/ffprobe" and "/var/task/node_modules/get-video-duration/node_modules/@ffprobe-installer/ffprobe/node_modules/@ffprobe-installer/linux-x64/ffprobe"

Sumolari commented 10 months ago

@mxnuchim @milesyang0220 Have you tried adding unsafe-perm=true to your .npmrc file?

This is a known issue in @ffprobe-installer/ffprobe, which get-video-duration depends on.

@atumas-bananamilk Let's keep this thread focused on AWS EC2 issues. I'm not familiar with Vercel but there are a few reports of ffprobe not working in that environment (1, 2).

atumas-bananamilk commented 10 months ago

@Sumolari Vercel runs on AWS EC2.. Look at the error..

gTonelli commented 10 months ago

I have the same error as the original posters on EC2. unsafe-perm is set to true.

Error: Command was killed with SIGSEGV (Segmentation fault): /home/ubuntu/pds-backend/node_modules/@ffprobe-installer/linux-x64/ffprobe -v error -show_format -show_streams https://*********.s3-accelerate.amazonaws.com/**********.mp4 0|pds-backend | at makeError (/home/ubuntu/pds-backend/node_modules/execa/lib/error.js:60:11) 0|pds-backend | at handlePromise (/home/ubuntu/pds-backend/node_modules/execa/index.js:118:26) 0|pds-backend | at runMicrotasks (<anonymous>) 0|pds-backend | at processTicksAndRejections (internal/process/task_queues.js:95:5) { 0|pds-backend | shortMessage: 'Command was killed with SIGSEGV (Segmentation fault): /home/ubuntu/pds-backend/node_modules/@ffprobe-installer/linux-x64/ffprobe -v error -show_format -show_streams https://***********.s3-accelerate.amazonaws.com/*************.mp4', 0|pds-backend | command: '/home/ubuntu/pds-backend/node_modules/@ffprobe-installer/linux-x64/ffprobe -v error -show_format -show_streams https://***************.s3-accelerate.amazonaws.com/****************.mp4', 0|pds-backend | escapedCommand: '"/home/ubuntu/pds-backend/node_modules/@ffprobe-installer/linux-x64/ffprobe" -v error -show_format -show_streams "https://***********.s3-accelerate.amazonaws.com/*********.mp4"', 0|pds-backend | exitCode: undefined, 0|pds-backend | signal: 'SIGSEGV', 0|pds-backend | signalDescription: 'Segmentation fault', 0|pds-backend | stdout: '', 0|pds-backend | stderr: '', 0|pds-backend | failed: true, 0|pds-backend | timedOut: false, 0|pds-backend | isCanceled: false, 0|pds-backend | killed: false 0|pds-backend | }

I suppose this is an issue with ff-probe though, so maybe we should report it there?

UnderscoreNorth commented 9 months ago

I don't know if this helps, but I ran into a similar issue on a Debian VPS, and seemed to have resolved it by installing ffmpeg package on the OS, and then calling that ffprobe instead of the one that's installed by @ffprobe-installer

getVideoDurationInSeconds(mediaURL) -> getVideoDurationInSeconds(mediaURL, "ffprobe")

Sumolari commented 9 months ago

I think this might be related to ffprobe having glibc statically linked and not being able to do DNS resolution. Could you try installing nscd through your package manager and check if the issue persist?

Spectrumsun commented 9 months ago

I don't know if this helps, but I ran into a similar issue on a Debian VPS, and seemed to have resolved it by installing ffmpeg package on the OS, and then calling that ffprobe instead of the one that's installed by @ffprobe-installer

getVideoDurationInSeconds(mediaURL) -> getVideoDurationInSeconds(mediaURL, "ffprobe")

Worked for me Thanks

rmahtoa commented 3 months ago

same issue on aws ECS Error: ffprobe was killed with signal SIGSEGV\nffprobe version 4.0.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2018 the FFmpeg developers\n built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516\n configuration: --enable-gpl \

danny-does-stuff commented 1 month ago

We also ran into this issue when upgrading our docker image from node 16 to node 20. Our Dockerfile was as follows

#####################################################################################
# Step 1 : Builder image
# use node image
FROM node:20-alpine AS builder

# change directory
WORKDIR /usr/src/app

# copy and install requirements
COPY package.json yarn.lock ./
RUN yarn safe-install-lock

# copy and build source
COPY . .
RUN yarn build

#####################################################################################
# Step 2 : Run image

FROM node:20

# change directory
WORKDIR /usr/src/app

# copy and install requirements
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production

# copy and build source
COPY --from=builder /usr/src/app/build ./build

# expose needed ports
EXPOSE 8000

# start app
CMD ["yarn", "start-production"]

We solved it by following @UnderscoreNorth 's comment, i.e. adding RUN apt-get update && apt-get install -y ffmpeg to our Run image and passing "ffprobe" as the second argument to getVideoDurationInSeconds. We needed to do the same for getAudioDurationInSeconds from the get-audio-duration package.

danny-does-stuff commented 1 month ago

@Sumolari Do you have any idea why this would only be happening on newer images? In our case, it fails on node:20 but worked on node:16

Sumolari commented 1 month ago

@danny-does-stuff No idea why Node 20 image would break ffmpeg. It's hard to tell because node:20 and node:16 are both ambiguous versions: those tags point to the latest release in the 20.x and 16.x versions, so you might run into situations where today's node:16 works but next week you build "the same image" and it fails because now node:16 points to some different base image

If you compare 2 recent versions of node:16 and node:20 you can see that they have a different amount of packages (node:20 has 4 fewer packages)

Maybe it's one of those missing packages, or some package that was updated, it's hard to tell

If manually installing ffmpeg solves the issue that's a useful patch. However, I think the issue should be forwarded to https://github.com/SavageCore/node-ffprobe-installer, although seems to be the same issue as https://github.com/SavageCore/node-ffprobe-installer/issues/121