Giter Club home page Giter Club logo

mp3info's Introduction

Compute variable bitrate (VBR) Mp3 duration in Elixir

Demo

Note: I couldn't find a VBR file online, so this only shows it working on a constant bitrate file.

$ iex -S mix
Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Compiling 1 file (.ex)
Interactive Elixir (1.6.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> {:ok, resp} =  HTTPoison.get("http://s3.amazonaws.com/thinkrelevance-podcast/ThinkRelevance-014-rich-hickey.mp3")                       
{:ok,
 %HTTPoison.Response{
   body: <<73, 68, 51, 3, 0, 0, 0, 1, 103, 68, 84, 65, 76, 66, 0, 0, 0, 57, 0,
     0, 1, 255, 254, 84, 0, 104, 0, 105, 0, 110, 0, 107, 0, 82, 0, 101, 0, 108,
     0, 101, 0, 118, 0, 97, 0, 110, 0, ...>>,
   headers: [
     {"x-amz-id-2",
      "DQkXKn5BUj2VNW2e1fpxhL/iZ8u6/rDrguDhgAHQQ8iAtBODx6nKXciLoT4ZUaehBFNSSF7m+Wc="},
     {"x-amz-request-id", "80FC4C1A274BC889"},
     {"Date", "Sat, 31 Mar 2018 21:49:16 GMT"},
     {"Last-Modified", "Sat, 28 Jul 2012 17:17:25 GMT"},
     {"ETag", "\"f1bcb7cb764ce1c562c58bba98219bce\""},
     {"Accept-Ranges", "bytes"},
     {"Content-Type", "audio/mpeg"},
     {"Content-Length", "27822386"},
     {"Server", "AmazonS3"}
   ], 
   request_url: "http://s3.amazonaws.com/thinkrelevance-podcast/ThinkRelevance-014-rich-hickey.mp3",
   status_code: 200
 }}
iex(2)> resp |> Map.get(:body) |> Mp3Info.duration
1737.064

LICENCE

Copyright (c) Dieter Komendera and contributors Distributed under the Eclipse Public License 1.0.

mp3info's People

Contributors

kommen avatar

Stargazers

Павел "Malo" Скрылёв  avatar Mat Garland avatar Roger Pinho avatar Gerald Philip MacKenzie avatar Jeroen Visser avatar Konstantin Zolotarev avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.