Skip to content

Instantly share code, notes, and snippets.

@Newlifer
Forked from liamcurry/FFMpeg - FLAC to Ogg
Created September 23, 2016 17:42
Show Gist options
  • Save Newlifer/87fb1da54978006a430a7c178bbed3bf to your computer and use it in GitHub Desktop.
Save Newlifer/87fb1da54978006a430a7c178bbed3bf to your computer and use it in GitHub Desktop.
Converting FLAC to various formats
ffmpeg -i name.flac -acodec alac name.m4a
ffmpeg -i name.flac -acodec libmp3lame -ab 320k -ac 2 -ar 48000 name.mp3
ffmpeg -i hlah_3.flac -strict experimental -acodec vorbis -aq 100 hlah.ogg
#!/usr/bin/python
import gobject
import gst
converter = gst.Pipeline('converter')
source = gst.element_factory_make('filesrc', 'file-source')
source.set_property('location', 'test.flac')
decoder = gst.element_factory_make('flacdec', 'decoder')
encoder = gst.element_factory_make('lame', 'encoder')
sink = gst.element_factory_make('filesink', 'sink')
sink.set_property('location', 'test.mp3')
converter.add(source, decoder, encoder, sink)
gst.element_link_many(source, decoder, encoder, sink)
converter.set_state(gst.STATE_PLAYING)
gobject.threads_init()
gobject.MainLoop().run()
#!/usr/bin/python
import gst
import gobject
import os
dirname = os.path.dirname(os.path.abspath(__file__))
source = os.path.join(dirname, 'test.flac')
dest = os.path.join(dirname, 'test.mp3')
pipeline = gst.parse_launch('filesrc location="%s" ! flacdec ! lame ! filesink location="%s"' % (source, dest))
pipeline.set_state(gst.STATE_PLAYING)
gobject.threads_init()
gobject.MainLoop().run()
# wav -> ogg
gst-launch filesrc location=music.wav ! wavparse ! audioconvert ! vorbisenc ! oggmux ! filesink location=music.ogg
# wav -> mp3
gst-launch filesrc location=music.wav ! wavparse ! audioconvert ! lame ! filesink location=music.mp3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment