Skip to content

Instantly share code, notes, and snippets.

@yoannmoinet
Created November 29, 2017 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yoannmoinet/97d9e3fe479fa3bf9132bff184443f03 to your computer and use it in GitHub Desktop.
Save yoannmoinet/97d9e3fe479fa3bf9132bff184443f03 to your computer and use it in GitHub Desktop.
Stream video back in correct format.
import ffmpeg form 'fluent-ffmpeg';
const filePath = '/Users/yoann/Desktop/video.avi';
const route = (req, res) => {
res.writeHead(200, getHeaders({'Content-Type': 'video/mp4'}));
ffmpeg(filePath)
.format('mp4')
.addOptions([
'-movflags frag_keyframe+faststart'
])
.pipe(res, {end: true});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment