• Stars
    star
    342
  • Rank 123,697 (Top 3 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

youtube audio stream

youtube-audio-stream

js-standard-style ci

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 with brew install ffmpeg.

Getting Started

  1. With npm, run npm install youtube-audio-stream
  2. const stream = 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. write it to res
const stream = require('youtube-audio-stream')
async function handleView (req, res) {
  try {
    for await (const chunk of stream(`http://youtube.com/watch?v=${req.params.videoId}`)) {
      res.write(chunk)
    }
    res.end()
  } catch (err) {
    console.error(err)
    if (!res.headersSent) {
      res.writeHead(500)
      res.end('internal system error')
    }
  }
}

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

More Repositories

1

aws-lambda-ws-server

aws lambda websocket server.
JavaScript
38
star
2

dialogs

non blocking confirm, alert and prompt dialogs.
JavaScript
35
star
3

electron-screenshot

Take screenshots in an electron window
JavaScript
35
star
4

soundify

streaming youtube, soundcloud and spotify
JavaScript
22
star
5

svg-sketch

svg sketch widget
JavaScript
20
star
6

aws-lambda-http-server

run your http server in a aws lambda function
JavaScript
19
star
7

graphql2cypher

graphql parser to cypher
JavaScript
18
star
8

install-missing

installs missing modules and saves as dependencies in package.json
JavaScript
11
star
9

svg-sketch-pdf

svg-sketch pdf creation
JavaScript
10
star
10

sandbox-debugger

sandbox debugger for node
JavaScript
9
star
11

tape-run-electron

run tests in electron like a boss
JavaScript
9
star
12

svg-to-canvas

svg-to-canvas
JavaScript
8
star
13

level-airplanedb

offline leveldb library with sync feature
JavaScript
8
star
14

server-base

base for micro services or simple servers
JavaScript
7
star
15

fetch-lambda

fetch for lambda bypassing api gateway
JavaScript
7
star
16

level-eventstore

eventstore implemented using leveldb-mount, leveldb and level-logs
JavaScript
7
star
17

graphqlcypherquery

streaming rest api for neo4j using graphql
JavaScript
6
star
18

canvas-colorpicker

canvas colorpicker
JavaScript
5
star
19

graphicsmagick-alpine

graphicsmagick alpine image with webp support
Dockerfile
5
star
20

busboy-wrapper

busboy multi part file wrapper
JavaScript
4
star
21

aws-lambda-layers

AWS lambda runtime & layers
Shell
3
star
22

svg-sketch-controls

svg drawing controls for svg-sketch
JavaScript
3
star
23

react-drag-drop

A simple react component for wrapping drag and drop functionality.
JavaScript
3
star
24

observable-form

Observable form
JavaScript
3
star
25

level-range-emitter

level-range-emitter
JavaScript
3
star
26

range-emitter

range emitter
JavaScript
3
star
27

dynamodb-logs

sample repo to use dynamodb with append only logs
JavaScript
3
star
28

aws-lambda-ws-server-example

JavaScript
2
star
29

electron-breakpoint

Make the electron window visible, open dev tools and break.
JavaScript
2
star
30

leveldb-mount

leveldb with backend + optional repl built with subleveldown and multileveldown.
JavaScript
2
star
31

fontello-server

A cdn fontello server
JavaScript
2
star
32

inline-templates

JavaScript
2
star
33

google-cloud-function-http-server

run your http server as a google cloud function
JavaScript
2
star
34

dependency-sync

dependency-sync
JavaScript
2
star
35

ops-kitchen

kitchen sink docker ops image
Dockerfile
2
star
36

gauge-progress

gauge progress
JavaScript
2
star
37

dynamodb-query-cli

dynamodb query cli
JavaScript
2
star
38

jof

For quick prototyping write server and client code in a single file
JavaScript
1
star
39

cypherquery

streaming rest api for neo4j
JavaScript
1
star
40

create-self-signed

A Docker image that will create self signed certificates.
Shell
1
star
41

docker-env

set docker environment
JavaScript
1
star
42

aws-lambda-compiler-node

aws lambda compiler for node
1
star
43

server-base-docker

node docker images
1
star
44

music-workshop-recorder

Music workshop recorder
JavaScript
1
star
45

lazyrethink

lazy rethinkdbdash wrapper
JavaScript
1
star
46

node-docker

node docker images
Dockerfile
1
star
47

unzip-maybe

Transform stream that unzips a azip or just echoes it if not.
JavaScript
1
star
48

Javascript-bundle

1
star
49

aws-lambda-redirect

aws lambda redirect for api gateway
JavaScript
1
star
50

electron-debugger

electron-debugger
JavaScript
1
star
51

mobile-fix-orientation-change

rescale mobile web page when orientation changes
JavaScript
1
star
52

graphql-create-schema

JavaScript
1
star
53

aoc

adventofcode
JavaScript
1
star
54

devops

devops image for aws, node, lambda et. al
Dockerfile
1
star
55

dev-sqs

development sqs server
JavaScript
1
star
56

james-dev-setup

James' osx dev setup
Vim Script
1
star
57

fontello-mount

mount fontello assets in a http route without files
JavaScript
1
star
58

three-hello-world

JavaScript
1
star
59

serve-create-react-app

serve-create-react-app
JavaScript
1
star
60

docker-node-debug

debug docker containers
Shell
1
star