This is easy to do if you have `youtube-dl`. ¹
`youtube-dl.exe --extract-audio --audio-format mp3 https://youtu.be/...`
On Windows, you need to install both youtube-dl and ffmpeg for Windows:
`./youtube-dl.exe --extract-audio --audio-format=mp3 --ffmpeg-location=/Portable\ Programs/ffmpeg-20161218-02aa070-win64-static/bin/ffmpeg.exe https://www.youtube.com/watch?v=u4DZPemB4uI`
If you downloaded the mp4 file and forgot the transformation to mp3, you can do that, too:
ffmpeg -i somefile.mp4 -q:a 0 -map a somefile.mp3
This will give you one big file. But if you know the number of tracks, you can get a copy of mp3splt. I got the zipfile, unzipped it, and ran it on my file as follows, given that I knew this file contained 25 tracks:
mp3splt_2.6.2_i386/mp3splt.exe -s -p nt=25,rm foo.mp3
And here’s how you can add the metadata, if you have the track list:
i=1 while read title; do file="fileprefix_$(printf "%02d" $i).mp3" mp3info -a "artist" -c "URL or whatever" -g 24 -l "album" -n $i -t "$title" -y 2013 "$file" i=$(($i + 1)) done <<EOF title for track 1 title for track 2 title for track 3 title for track 4 ... title for track 25 EOF
#Music
(Please contact me if you want to remove your comment.)
⁂
@fitheach said that this will be re-encoding the audio from one lossy to another, and this is true. Here’s an alternative:
youtube-dl -F https://www.youtube.com/watch?v=QS6b8JKzUeo
This shows the existing formats and their codes (first column). You could download WebM with Opus or Vorbis, for example. Use `-f` and the code you want to download just that format.
Then use ffmpeg to copy out the audio (example Vorbis):
ffmpeg -i "$file" -vn -acodec copy "OGG/$nosuffix.ogg"
You need to know the codecs your player supports, of course. Perhaps mp3 is all it can do. I installed Rockbox on my iPod, however, and it supports a lot, apparently!
– Alex Schroeder 2019-04-19 08:39 UTC
---
Today I saw @unfa suggest the following for shaky video:
for i in *.m[pk][4v]; do ffmpeg -i "$i" -vf "deshake=blocksize=128:rx=64:ry=64" -c:a copy -b:v 30M "deshake-$i"; done
tag(video) tag(videoproduction) tag(ffmpeg)
– Alex 2021-08-14 14:14 UTC