Created
April 19, 2019 04:05
-
-
Save niusounds/2fac61c62a0966cdda2211eb2d9fe6f1 to your computer and use it in GitHub Desktop.
ffmpeg live transcode test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const app = express() | |
const { spawn } = require('child_process'); | |
const URL = 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8' | |
app | |
.get('/video.webm', (req, res) => { | |
res.type('video/webm') | |
const ls = spawn('ffmpeg', ['-i', URL, '-f', 'webm', '-']); | |
ls.stdout.pipe(res) | |
ls.stderr.on('data', (data) => { | |
console.log(`${data}`); | |
}); | |
}) | |
.get('/', (req, res) => { | |
res | |
.type('html') | |
.sendFile(__dirname + '/index.html') | |
}) | |
.listen(3000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<video src="video.webm" controls></video> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment