Skip to content

Instantly share code, notes, and snippets.

@miohtama
Created May 18, 2012 22:25
Show Gist options
  • Save miohtama/2727891 to your computer and use it in GitHub Desktop.
Save miohtama/2727891 to your computer and use it in GitHub Desktop.
Create HTML5 <audio> compatible files out of MP3 using ffmpeg
# -*- coding: utf8 -*-
import os
import subprocess
def create_prelisten_ogg(mp3, ogg):
"""
Run en-code for a single file
Do 48 kbit files for prelisten.
"""
FFMPEG = os.environ['FFMPEG']
cmdline = [ FFMPEG, '-y', '-i', mp3, '-acodec', 'libvorbis', '-ar', '22050', '-ac', '1', '-ab', '48000', ogg ]
return subprocess.call(cmdline)
def create_prelisten_aac(mp3, aac):
"""
Run en-code for a single file
Do 48 kbit files for prelisten.
"""
FFMPEG = os.environ['FFMPEG']
cmdline = [ FFMPEG, '-y', '-i', mp3, '-acodec', 'libfaac', '-ar', '22050', '-ac', '1', '-ab', '48000', aac ]
return subprocess.call(cmdline)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment