Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewhudson/31a78b95cbb2329f82c6bc5d03a1b617 to your computer and use it in GitHub Desktop.
Save matthewhudson/31a78b95cbb2329f82c6bc5d03a1b617 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