caffco / get-video-duration

Get the duration of a video file
MIT License
140 stars 18 forks source link

Can't get duration on Ubuntu Linux machines? #27

Closed adib1996 closed 3 years ago

adib1996 commented 3 years ago

Hello!

When trying to run this piece of code, it works fine on my local machine.

const { getVideoDurationInSeconds } = require('get-video-duration')

getVideoDurationInSeconds('https://instagram.ffjr1-4.fna.fbcdn.net/v/t50.2886-16/131687230_388727058869326_3901901103341180755_n.mp4?_nc_ht=instagram.ffjr1-4.fna.fbcdn.net&_nc_cat=110&_nc_ohc=DO0V2EPdiqEAX-EbIwf&oe=5FE1FCD0&oh=8f8e0506f15cb4ac3766a0ec3606758e').then((duration) => {
  console.log(duration)
})

However when trying to run this on a Remote Server running Ubuntu, I'm met with this error.

(node:97616) UnhandledPromiseRejectionWarning: Error: Command failed with exit code 1: /home/ubuntu/Whatsapp-Helper/node _modules/@ffprobe-installer/linux-x64/ffprobe -v error -show_format -show_streams https://instagram.ffjr1-4.fna.fbcdn.net/ v/t50.2886-16/131687230_388727058869326_3901901103341180755_n.mp4?_nc_ht=instagram.ffjr1-4.fna.fbcdn.net&_nc_cat=110&_nc_o hc=DO0V2EPdiqEAX-EbIwf&oe=5FE1FCD0&oh=8f8e0506f15cb4ac3766a0ec3606758e https://instagram.ffjr1-4.fna.fbcdn.net/v/t50.2886-16/131687230_388727058869326_3901901103341180755_n.mp4?_nc_ht=instagram .ffjr1-4.fna.fbcdn.net&_nc_cat=110&_nc_ohc=DO0V2EPdiqEAX-EbIwf&oe=5FE1FCD0&oh=8f8e0506f15cb4ac3766a0ec3606758e: Resource t emporarily unavailable at makeError (/home/ubuntu/Whatsapp-Helper/node_modules/execa/lib/error.js:59:11) at handlePromise (/home/ubuntu/Whatsapp-Helper/node_modules/execa/index.js:114:26) at processTicksAndRejections (internal/process/task_queues.js:93:5) (Use node --trace-warnings ... to show where the warning was created) (node:97616) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing insid e of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/ api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:97616) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I can't think of any other reason why this is showing up aside from having different OS. I've installed get-video-duration on both machines.

Thanks in advance

Sumolari commented 3 years ago

https://instagram.ffjr1-4.fna.fbcdn.net/v/t50.2886-16/131687230_388727058869326_3901901103341180755_n.mp4?_nc_ht=instagram .ffjr1-4.fna.fbcdn.net&_nc_cat=110&_nc_ohc=DO0V2EPdiqEAX-EbIwf&oe=5FE1FCD0&oh=8f8e0506f15cb4ac3766a0ec3606758e: Resource t emporarily unavailable

Looks like the video you tried to analyze was temporarily down. If the errors persists, is it possible that Instagram is throttling or preventing your server from reaching the file?

adib1996 commented 3 years ago

Apologies for the delayed response. Didn't get notified by Github. It seems that Instagram puts up a auth wall asking us to log in hence this happens. My local has cookies from my previous sessions so that helped bypass it.

I wrote a little code in javascript with ffmpeg that might help with anyone who faced a similar issue

const ffmpeg = require('fluent-ffmpeg');

module.exports = getVideoDurationInSeconds = async function (url){

    return await new Promise((resolve, reject) => {

        ffmpeg.ffprobe(url, function(err, metadata) {

            resolve(metadata.format.duration);

        });

    })
}
DUMENA commented 1 year ago

Apologies for the delayed response. Didn't get notified by Github. It seems that Instagram puts up a auth wall asking us to log in hence this happens. My local has cookies from my previous sessions so that helped bypass it.

I wrote a little code in javascript with ffmpeg that might help with anyone who faced a similar issue

const ffmpeg = require('fluent-ffmpeg');

module.exports = getVideoDurationInSeconds = async function (url){

    return await new Promise((resolve, reject) => {

        ffmpeg.ffprobe(url, function(err, metadata) {

            resolve(metadata.format.duration);

        });

    })
}

Thanks! This did it for me.