Git Product home page Git Product logo

zio-av's Introduction

ZIO AV

ZIO AV is a library for audio (video coming soon) processing with ZIO, built on top of the FFmpeg libraries using JavaCPP and JavaCV. It provides a simple way to work with audio data, enabling you to perform various operations such as transcoding (encode audio with different codec, sample rate, bitrate), getting audio metadata, cropping audio and etc.

Development Sonatype Snapshots ZIO AV

Features

Working with audio

  • Transcoding: transcode your audios to other format, change codec and other parameters.
  • Metadata: retrieve audio metadata
  • Cropping: cut necessary passages from audio
  • VAD: detect voice in audio (only for audio with dialogs, not for music)

Getting Started

Installation

Add the following dependency to your build.sbt file:

libraryDependencies += "io.github.victornguen" %% "zio-av" % "<version>"

Since library uses TarsosDSP, you need to add following resolver:

resolvers += "be.0110.repo-releases" at "https://mvn.0110.be/releases"

Example

Here's a simple example that demonstrates how to transcode MP3 to WAV with downsampling to 8 kHz:

import com.github.victornguen.av.settings.{AVLogLevel, AudioCodec, AudioFormat}
import com.github.victornguen.av.storage.DefaultTempFileStorage
import com.github.victornguen.av.{Audio, Multimedia}
import zio.{Console, Scope, ZIO, ZIOAppArgs, ZIOAppDefault}

import java.io.File

object TranscodingExample extends ZIOAppDefault {
  override def run: ZIO[Environment with ZIOAppArgs with Scope, Any, Any] = {
    val audioFilePath = "zio-av-examples\\src\\main\\resources\\Shooting Stars.mp3"
    val file          = new File(audioFilePath)
    for {
      _            <- Multimedia.setLogLevel(AVLogLevel.Info)
      _            <- Multimedia.logToFile(new File("./log.log"))
      audio        <- Audio.fromFile(file)
      newAudio     <- audio.transcode(AudioCodec.PCM.S16LE, AudioFormat.WAV, Some(8000))
      newAudioInfo <- newAudio.getInfo
      newAudioFile <- newAudio.getFile
      _            <- Console.printLine(newAudioInfo)
      _            <- Console.printLine(newAudioFile.toString)
    } yield ()
  }
    .provide(
      DefaultTempFileStorage.makeLayer,
      Scope.default,
    )
}

More examples available in zio-av-examples.

Contributing

Contributions to zio-av are welcome! If you find any issues or have suggestions for improvements, please submit a bug report or feature request in the issue tracker. Pull requests are also appreciated.

License

This project is licensed under the Apache 2.0 License.

zio-av's People

Contributors

dependabot[bot] avatar victornguen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.