Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

615
Views
Combinar audio con transmisión de video Node.js

Estoy creando un descargador de videos de YouTube y estoy trabajando con la biblioteca ytdl-core y no puedo descargar videos de alta calidad con audio, porque YouTube lo tiene en otros archivos, pero necesito descargarlo todo en un solo archivo.

ya hice esto

 app.get('/download', async (req, res, next) => { const { videoId, format } = req.query; ytdl.getInfo(videoId) .then(info => { const { title } = info.videoDetails; res.header('Content-Disposition', `attachment; filename=${title}.mp4`); const streams = {} if (format === 'video') { const resolution = req.query.resolution; const videoFormat = chain(info.formats) .filter( format => format.height === +resolution && format.videoCodec?.startsWith('avc1') ) .orderBy('fps', 'desc') .head() .value(); streams.video = ytdl(videoId, { quality: videoFormat.itag, format: 'mp4', }); streams.audio = ytdl(videoId, { quality: 'highestaudio' }); } }); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Aquí hay un ejemplo para usted usando FFmpeg

 import ffmpegPath from 'ffmpeg-static'; import cp from 'child_process'; import stream from 'stream'; import ytdl from "ytdl-core"; const ytmixer = (link, options = {}) => { const result = new stream.PassThrough({ highWaterMark: (options as any).highWaterMark || 1024 * 512 }); ytdl.getInfo(link, options).then(info => { let audioStream = ytdl.downloadFromInfo(info, { ...options, quality: 'highestaudio' }); let videoStream = ytdl.downloadFromInfo(info, { ...options, quality: 'highestvideo' }); // create the ffmpeg process for muxing let ffmpegProcess = cp.spawn(ffmpegPath, [ // supress non-crucial messages '-loglevel', '8', '-hide_banner', // input audio and video by pipe '-i', 'pipe:3', '-i', 'pipe:4', // map audio and video correspondingly '-map', '0:a', '-map', '1:v', // no need to change the codec '-c', 'copy', // output mp4 and pipe '-f', 'matroska', 'pipe:5' ], { // no popup window for Windows users windowsHide: true, stdio: [ // silence stdin/out, forward stderr, 'inherit', 'inherit', 'inherit', // and pipe audio, video, output 'pipe', 'pipe', 'pipe' ] }); audioStream.pipe(ffmpegProcess.stdio[3]); videoStream.pipe(ffmpegProcess.stdio[4]); ffmpegProcess.stdio[5].pipe(result); }); return result; }; ytmixer('Your Url').pipe(res);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!