d-ffmpeg-light 0.0.2

ffmpeg wrapper function


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

d-ffmpeg-light: ffmpeg wrapper for D

This library is thin wrapper to call ffmpeg to extract audio in subprocess.

usage

import dffmpeg;
import std.stdio;
import std.net.curl;

void main() {
    // prepare audio supported by ffmpeg (e.g., mp3, wav, ..., etc)
    auto file = "test10k.wav";
    download("https://raw.githubusercontent.com/ShigekiKarita/torch-nmf-ss-toy/master/test10k.wav", file);

    // you can ask audio info to ffprobe
    assert(ask(file, "sample_rate").to!size_t == 10000);
    assert(ask(file, "channels").to!size_t == 1);

    // load audio (short is nice for PCM16 here)
    auto wav = Audio!short().load(file);
    assert(wav.data.length == 62518);
    assert(wav.sample_rate == 10000);
    assert(wav.sample_fmt.startsWith("s16"));

    // audio info now (maybe resampled or requantized)
    writeln(wav.now);
    // audi info then (origin settings)
    writeln(wav.then);

    // save audio
    auto file2 = "test.wav";
    wav.save(file2);
    // if you want to keep origin settings
    wav.save("origin.wav", false);

    // reload audio
    auto wav2 = Audio!short().load(file2);
    assert(wav == wav2);
}

for heavy usage, I recommend you https://github.com/ljubobratovicrelja/ffmpeg-d

Authors:
  • Shigeki Karita
Dependencies:
none
Versions:
0.0.2 2018-Feb-22
0.0.1 2018-Feb-21
~master 2018-Feb-22
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 375 downloads total

Score:
0.5
Short URL:
d-ffmpeg-light.dub.pm