Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with extracted MP3 using Youtube-dl on Windows

I subscribe to various free music channels on YouTube and I'm looking to embed youtube-dl.exe in a .net program to monitor the channels and download and convert the songs as they are posted to the channels. I've gotten that part of the program working but there seems to be an issue with the mp3 files that are produced by youtube-dl. The files will play in VLC and Windows Media Player but if I try to open the files in an editor such as Audacity or Wavepad the files won't play and I've seen the following error when opening the file "Exception with MPEG Frame info: The data read as the MEPG header indicates a duration of zero". When played in the editor a blip of noise or distorted sound plays for a second to a few seconds depending on length of the song and the track will show as completed playing.

This issue also seems to affect ID3 tags. As soon as an ID3 tag is embedded the file will appear to play for a second then show completed in windows media player and will play with no sound in VLC. The ID3 tag info is picked up however so the file is not corrupted and removing the ID3 frames allows the song to play again but doesn't fix the other issues.

The arguments I'm using are: youtube-dl.exe videoURL-x --audio-format mp3 -o "path/filename.mp3"

I have the latest version at time of writing: 2015-03-24 and I've both used the --update flag and downloaded a fresh copy to rule out a corrupted exe

I've tried both the 32 and 64 bit versions of ffprobe.exe and ffmpeg.exe and downloaded fresh copies of each to rule out a corrupted exe

I've downloaded both through my program and using command line with the same results

I've tried various different songs so it's not just one video

I've tested the ID3 embedding software on songs produced from other software and it worked without issue

Any help you could offer on this issue would be appreciated.

like image 319
Chris Avatar asked Mar 25 '15 23:03

Chris


1 Answers

I figured out the issue and I'm posting it here in case someone else runs across the same issue. The issue was that I was specifying the whole path for the file in the -o template. The path looked like -o "c:\music\filename.mp3" changing the template to -o "c:\music\filename.%(ext)s" fixed the issue. %(ext)s is a special field that can be used in the output template to output the file extension.

The reason this caused an error is due to the order of operations for the conversion. First the file is downloaded in video format and saved to the hard drive. It is then converted into .mp3 and the source file is removed.

Due to my template the video file was being saved as video_name.mp3 regardless of actual video format and the converted file was overwriting this video "mp3". Hopefully this explanation saves someone else the same trouble I had in the future.

like image 51
Chris Avatar answered Sep 20 '22 00:09

Chris