Downloading youtube videos is easy with python script youtube-dl. However many times you would want to extract the audio from the downloaded video. On normal installation you would be able to extract audio from youtube-dl itself ( using ffmpeg), however on qnap that option doesn’t work.
So after downloading mp4 videos, it has to be converted to mp3. My choice of programs are ffmpeg and lame.
First, Install lame and ffmpeg
ipkg install lameipkg install ffmpeg
Now it’s a pity that I can’t encode from MP4 to MP3 using ffmpeg alone , even specifying lame as audio codes using -acodec option doesn’t work. So I am going to first convert MP4 to wave and then pipe the result to lame spitting out an mp3
ffmpeg -i inputfile.mp4 -f wav – | lame – output.mp3
Better yet, make a script to convert every mp4 file in a directory. Then you can put all your MP4 in a directry and let the script convert each file one by one
for file in ./*
do
ffmpeg -i “$file” -f wav – | lame – “$file.mp3”
done