Giter Site home page Giter Site logo

youtube-audio-stream's Introduction

youtube-audio-stream

js-standard-style Greenkeeper badge

This module streams youtube using ytdl to get the youtube download stream.

To convert to audio the module fluent-ffmpeg is used.

You will need to have ffmpeg and the necessary encoding libraries installed, as well as in your PATH. If you're on OSX, this can be handled easily using Homebrew (brew install ffmpeg).

Getting Started

  1. With npm, run npm install youtube-audio-stream
  2. var youtubeStream = require('youtube-audio-stream')

Usage

Here is an example that:

  1. queries for a video by video ID
  2. Retrieves the audio via this package
  3. pipes it to res
var getAudio = function (req, res) {
  var requestUrl = 'http://youtube.com/watch?v=' + req.params.videoId
  try {
    youtubeStream(requestUrl).pipe(res)
  } catch (exception) {
    res.status(500).send(exception)
  }
}

Node example playing directly to speaker

const stream = require('youtube-audio-stream')
const url = 'http://youtube.com/watch?v=34aQNMvGEZQ'
const decoder = require('lame').Decoder
const speaker = require('speaker')

stream(url)
.pipe(decoder())
.pipe(speaker())

Testing

This package comes with a simple example for testing. This can be run with the command npm test, which will then serve the example at localhost:3000. The example consists of an <audio> component whose source is retrieved via this package.

Testing inside a docker container

You can test this module without the need o have ffmeg locally installed doing it inside a container.

To build the Docker image:

docker build . -t youtube-audio-stream-test

To run the test:

docker run --rm -it -p 3000:3000 youtube-audio-stream-test

youtube-audio-stream's People

Contributors

jameskyburz avatar greenkeeperio-bot avatar jakemmarsh avatar saranrapjs avatar greenkeeper[bot] avatar arjndr avatar calebeby avatar carloscasalar avatar fazendaaa avatar erlapso avatar booyaa 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.