.flv audio extraction

For downloading videos from YouTube, I use xVideoServiceThief which downloads the .flv file and optionally converts them to a different video format.

For music videos, the video track is not that interesting, and I'd rather like ogg/vorbis instead of the default aac audio format in the files.

The most easy way to extract audio from the .flv files and get a .ogg audio file from it is to use ffmpeg:

$ ffmpeg -i youtubemusicvideo.flv -vn -acodec libvorbis result.ogg

That's it. Nothing more.

Details

It seems strange that we need to actually specify options in ffmpeg since normally you only do

$ ffmpeg -i file.flv outfile.flac

- which automatically does the correct thing: Take file.flv, extract the audio stream, convert it to FLAC and save it into outfile.flac.

Now when doing that with outfile.ogg, we get:

$ ffmpeg -i file.flv outfile.ogg
Output #0, ogg, to 'outfile.ogg':
  Metadata:
    encoder         : Lavf52.64.2
    Stream #0.0(und): Video: libtheora, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 tbn, 25 tbc
    Stream #0.1(und): Audio: libvorbis, 44100 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0.1 -> #0.0
  Stream #0.0 -> #0.1
$ file outfile.ogg 
outfile.ogg: Ogg data, Theora video

This converted the .flv file to a .ogg video file with an Theora video and a Vorbis audio stream - remember that OGG is a container format, and ogg/vorbis the audio format:

To get rid of the video stream in our destination file, ffmpeg offers a -vn option:

$ ffmpeg -i file.flv -vn outfile.ogg
Output #0, ogg, to 'outfile.ogg':
  Metadata:
    encoder         : Lavf52.64.2
    Stream #0.0(und): Audio: flac, 44100 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0

$ file outfile.ogg 
outfile.ogg: Ogg data, FLAC audio

Now we got an .ogg file, but encoded with FLAC! That's still not what we want. ffmpeg lists all available codecs with -codecs, and we're actually able to encode ("E") with libvorbis:

$ ffmpeg -codecs|grep -i vorbis
  EA    libvorbis       libvorbis Vorbis
 D A    vorbis          Vorbis

Knowing that we can use libvorbis to encode the file's audio stream in ogg/vorbis, the resulting command is simple:

$ ffmpeg -i file.flv -acodec libvorbis -vn outfile.ogg
Output #0, ogg, to 'outfile.ogg':
  Metadata:
    encoder         : Lavf52.64.2
    Stream #0.0(und): Audio: libvorbis, 44100 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0

$ file outfile.ogg 
outfile.ogg: Ogg data, Vorbis audio, stereo, 44100 Hz, ~64000 bps, created by: Xiph.Org libVorbis I

Written by Christian Weiske.

Comments? Please send an e-mail. Or Reply or Like.