Converting .flv to .mp3 via command line? (Debian)

MannDude

Just a dude
vpsBoard Founder
Moderator
Best way to do this? See some use ffmpeg, some don't. I nab some YouTube vids from time to time (youtube-dl) of hard to find tunes. Would be nice to convert these .flv videos to .mp3s.

So what does everyone here use? Ffmpeg? Something else? It's not a big deal or I'd just Google it, figured I'd just open the discussion here.
 

HalfEatenPie

The Irrational One
Retired Staff
Well...  If i recall flv is mostly a flash video file.  Therefore there would be no direct mp3 converter unless you want it to get rid of the video data.  There is a few converters here and there but as a music snob you'll lose so much detail in the music file...  hell I have my issues with mp3s in general!  
 

Francisco

Company Lube
Verified Provider
I think pony uses mplayer.

I'll link him this and see if he'll drop some nuggets of knowledge :)

Francisco
 

drmike

100% Tier-1 Gogent
Well, as root:


apt-get install ffmpeg lame libavcodec-extra-53 mplayer


wget http://youtube-dl.org/downloads/2013.08.23/youtube-dl -O /usr/local/bin/youtube-dl
chmod a+x /usr/local/bin/youtube-dl



Now to use youtube-dl:


youtube-dl https://www.youtube.com/watch?v=1D1cap6yETA --extract-audio --audio-format mp3
Then play the new MP3 file:

Code:
mplayer Good\ News\ Everyone\!-1D1cap6yETA.mp3
 

MannDude

Just a dude
vpsBoard Founder
Moderator
Well...  If i recall flv is mostly a flash video file.  Therefore there would be no direct mp3 converter unless you want it to get rid of the video data.  There is a few converters here and there but as a music snob you'll lose so much detail in the music file...  hell I have my issues with mp3s in general!  
It is. I just want to convert the audio, guess I should have made the clear.
 

Aldryic C'boas

The Pony
This functionality is built into youtube-dl already.

Code:
Post-processing Options:
    -x, --extract-audio        convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)
    --audio-format FORMAT      "best", "aac", "vorbis", "mp3", "m4a", "opus", or "wav"; best by default
    --audio-quality QUALITY    ffmpeg/avconv audio quality specification, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default 5)
    --recode-video FORMAT      Encode the video to another format if necessary (currently supported: mp4|flv|ogg|webm)
    -k, --keep-video           keeps the video file on disk after the post-processing; the video is erased by default
    --no-post-overwrites       do not overwrite post-processed files; the post-processed files are overwritten by default
    --embed-subs               embed subtitles in the video (only for mp4 videos)
 

MannDude

Just a dude
vpsBoard Founder
Moderator
This functionality is built into youtube-dl already.


Post-processing Options:
-x, --extract-audio convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)
--audio-format FORMAT "best", "aac", "vorbis", "mp3", "m4a", "opus", or "wav"; best by default
--audio-quality QUALITY ffmpeg/avconv audio quality specification, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default 5)
--recode-video FORMAT Encode the video to another format if necessary (currently supported: mp4|flv|ogg|webm)
-k, --keep-video keeps the video file on disk after the post-processing; the video is erased by default
--no-post-overwrites do not overwrite post-processed files; the post-processed files are overwritten by default
--embed-subs embed subtitles in the video (only for mp4 videos)
Well hell's bells.
 

MannDude

Just a dude
vpsBoard Founder
Moderator
Yeah, I guess I should read the manpages for shit I download.... Been using youtube-dl for a little while, just never bothered to look too much into it.

Now I can upload music that I can't find in the TurnTable.FM library to play!
 

Aldryic C'boas

The Pony
Not really relevant to his question, but what Fran was referring to earlier is another nifty trick for youtube-dl + mplayer, especially for those of us that dislike ads:

Francisco said:
I think pony uses mplayer.
Used to, you could directly stream youtube URLs through mplayer.  Then a few years back, Youtube changed how .flvs were handled in an effort to prevent this (and other streaming tricks).  youtube-dl was the perfect fix, since it provided a direct link to the .flv URL.

Then Google got crafty, and started making Cookies (something mplayer cannot get on its own) mandatory, to try and force only web browsers.  Thankfully, the gentleman behind youtube-dl fixed that as well.


-11:03:38- Mokou:~ :: aldryic % cat .bin/youtube
mplayer -x 896 -y 504 -cookies -cookies-file /tmp/cookie.txt $(youtube-dl -g --cookies /tmp/cookie.txt "http://www.youtube.com/watch?v=$1")

-11:03:44- Mokou:~ :: aldryic % youtube oLGkyoriqvQ

This only works for those of us using *nix and mplayer, obviously :p  But it's a very handy way to stream Youtube content directly, without ads or all the other nonsense.
 

drmike

100% Tier-1 Gogent
The two steps in my solution which come from cobbling the docs shoved into a bash file to do more / be portable and reusable, that's the idea.  Use to have such a thing.   But low priority/disorganization and that script went vapor on me.
 
Top