Skip to content

Instantly share code, notes, and snippets.

@zlovatt
Created July 6, 2021 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zlovatt/c5f12937e6ea308b7fbc8ecc313dcc2d to your computer and use it in GitHub Desktop.
Save zlovatt/c5f12937e6ea308b7fbc8ecc313dcc2d to your computer and use it in GitHub Desktop.
Extendscript: get audio file bitrate
// This doesn't check that the selection is valid, or that it's an audio file.
// Based on: http://stackoverflow.com/questions/21634091/is-it-possible-to-get-bitrate-of-mp3
(function () {
var item = app.project.selection[0];
var duration = item.duration;
var fileSize = item.file.length;
var kbit = fileSize/128;
var kbps = Math.ceil(Math.round(kbit / duration) / 16) * 16;
$.writeln(kbps + " kbps");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment