node-ytdl-core icon indicating copy to clipboard operation
node-ytdl-core copied to clipboard

content length header with ffmpeg doesn't work

Open only1drhex opened this issue 3 years ago • 2 comments

I'm trying to add the content length header while converting to mp3 with ffmpeg but this just results in an endless download loop

var audio =  ytdl(url, {
            format: 'mp3',
            filter: 'audioonly',
            quality: 'highest'
        }).on("response", response => {

res.setHeader("content-length", response.headers["content-length"])
       var ffmpegProcess = spawn(ffmpeg,['-i','pipe:0','-acodec','libmp3lame','-b','128k','-f','mp3','-'])
         audio.pipe(ffmpegProcess.stdin)   
       ffmpegProcess.stdout.pipe(res)

       
 
  }) 

only1drhex avatar Mar 02 '22 23:03 only1drhex

i would actually expect this to straight up fail

  • options#format is not supposed to be a string and should result in the library throwing an error (see here)
  • you can't set the content-length header before being finished with the ffmpeg reencode... there's just no way of knowing the final size...

TimeForANinja avatar Mar 05 '22 00:03 TimeForANinja

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 10 '22 11:07 stale[bot]