Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use the modeules ffmpeg and ffprobe correctly? I have issues with the mp3 files. #21958

Closed
l1k2j3h4g5 opened this issue Jul 31, 2019 · 3 comments
Labels

Comments

@l1k2j3h4g5
Copy link

@l1k2j3h4g5 l1k2j3h4g5 commented Jul 31, 2019

Checklist

  • I'm asking a question
  • I've looked through the README and FAQ for similar questions
  • I've searched the bugtracker for similar questions including closed ones

Question

In the readme it says:

 -x, --extract-audio         Convert video files to audio-only files
                             (**requires ffmpeg or avconv and ffprobe or
                             avprobe**)

So I included that at the top of my node.js file:

const ffmpeg = require('ffmpeg');
const ffprobe = require('ffprobe');

In terminal I ran

$ npm install ffmpeg -save
$ npm install ffprobe -save

which gave me a package json file of:

"dependencies": {
   "ffmpeg": "0.0.4",
   "ffprobe": "^1.1.0",
   "youtube-dl": "1.13.1"
 },

My function that then downloads the file as mp3 and uploads it to S3 is:

exports.handler = function(event, context, cb) {   
  if (!event.videoUrl) {
    return cb(new Error('videoUrl missing in event'));
  }
  const s3 = new AWS.S3({apiVersion: '2006-03-01'});
  const passtrough = new stream.PassThrough();

  var downloadOptions = ['--extract-audio', '--audio-format', 'mp3']

  const dl = youtubedl(event.videoUrl, downloadOptions, {maxBuffer: Infinity});
  dl.once('error', (err) => {
    cb(err);
  });
  const key = `${context.awsRequestId}.mp3`;
  const upload = new AWS.S3.ManagedUpload({
    params: {
      Bucket: process.env.BUCKET_NAME,
      Key: key,
      Body: passtrough
    },
    partSize: 1024 * 1024 * 64 // in bytes
  });

  upload.on('httpUploadProgress', (progress) => {
    console.log(`[${event.videoUrl}] copying video ...`, progress);
  });

  upload.send((err) => {
    if (err) {
      cb(err);
    } else {
      cb(null, {
        bucketName: process.env.BUCKET_NAME,
        key,
        url: `s3://${process.env.BUCKET_NAME}/${key}`
      });
    }
  })
  

  dl.pipe(passtrough);
}

It downloads the file and saved it as .mp3 as expected.

So how do I know there is an issue?

Every time I try to use that file in an AWS Transcribe Job it says:

The media format provided does not match the detected media format.

and when I download the file and try to run it in VLC or iTunes it forces the player to close and does not play.

Do I need to do anything else to get the encoding correct?

@l1k2j3h4g5 l1k2j3h4g5 added the question label Jul 31, 2019
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jul 31, 2019

Wrong forum.

@dstftw dstftw closed this Jul 31, 2019
@l1k2j3h4g5
Copy link
Author

@l1k2j3h4g5 l1k2j3h4g5 commented Jul 31, 2019

is this the "question" section for the module "Youtube-dl" ?

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jul 31, 2019

No, youtube-dl has nothing to do with nodejs modules.

@ytdl-org ytdl-org locked and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.