Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

ofxAvCodec - ffmpeg wrapper for reading/writing audio files

$
0
0

hey.

I've been writing an ffmpeg wrapper to read/write audio files (and metadata) using FFmpeg. I think it's reached a point where it could be useful for other people.

  • Reads virtually any file format (including audio contained in videos, aac support disabled)
  • Writes a lot of formats (not aac, not mp3)
  • Resampling built into the player and file writer
  • Methods to read/write/update metadata
  • Utility to generate an ofPath representing the waveform from an audio file
  • Contains a readme file that explains how ffmpeg was compiled (must be included with your project if you distribute it publicly)
  • Has the funny name of ofxAvCodec, because it took me forever to understand the difference between FFmpeg, libav and libavcodec.

Here's a quick example (more are in the github readme):

#include "ofxAvAudioPlayer.h"

class ofApp : public ofBaseApp{
    // ...
    ofSoundStream soundStream;
    ofxAvAudioPlayer player;
    void audioOut( float * output, int bufferSize, int nChannels );
};

//--------------------------------------------------------------
void ofApp::setup(){
    soundStream.setup(this, 2, 0, 44100, 512, 4);
    player.setupAudioOut(2, 44100); // set up resampling
    player.loadSound(ofToDataPath("testo.flac"));
    map<string,string> metadata = player.getMetadata();
}

void ofApp::audioOut( float * output, int bufferSize, int nChannels ){
    player.audioOut(output, bufferSize, nChannels);
}

For this to work you'll also need the FFmpeg shared libraries. You can either compile them yourself (follow this guide: https://github.com/kritzikratzi/ofxAvCodec/blob/master/ffmpeg_src/readme.md or the ffmpeg compilation guide: https://trac.ffmpeg.org/wiki/CompilationGuide)

or instead take the libs i compiled here: https://www.wetransfer.com/downloads/81f26bbceec1d5a783fe8bc36de50b6420151218183950/bdd690f0b76d1f6fc5caafd89287710920151218183950/b6aeb9 contains source, linux32/64, win32/64, osx32, but i can't guarantee they'll work, i only tested half of them.


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>