6
votes

My Node.js app uses FFmpeg to capture video of a DirectShow device and then output segments for live streaming (HLS). At the moment I'm outputting the segments to files, however if I could output them via a pipe it would allow me to efficiently send the segment via a websocket instead of hosting a HTTP server.

I've tried using this command:

ffmpeg -y -f dshow -i video=FFsource:audio=Stereo Mix (Realtek High Definition Audio) -vcodec libvpx -acodec libvorbis -threads 0 -b:v 3300k -cpu-used 5 -keyint_min 150 -g 150 -map 0 -flags:v +global_header -f segment -

However it gives the error "Could not write header for output file #0 (incorrect codec parameters ?): Muxer not found". This commands works for outputting to files (by replacing '-' with 'seg_%03d.webm').

Does FFmpeg not support pipes for segmented video, or is there something wrong with the command? Thanks.

2
What does it mean to output segmented files on a pipe?vipw
did you find a solution?ESala

2 Answers

1
votes

Use -f nut instead of -f segment. The nut format could contain all types of headers and audio, video codecs.

ffmpeg -y -f dshow -i video=FFsource:audio=Stereo Mix (Realtek High Definition Audio) -vcodec libvpx -acodec libvorbis -threads 0 -b:v 3300k -cpu-used 5 -keyint_min 150 -g 150 -map 0 -flags:v +global_header -f nut pipe:
0
votes

You can pass ffmpeg -i pipe:0 pipe:1 to read from stdin and output to stdout.

You can take a look at an example FFmpeg wrapper I use in one of my projects:

https://github.com/lperrin/node_airtunes/blob/master/examples/play_ffmpeg.js

If you plan on streaming from the network, you might need a circular buffer at some point. There's one in the project you can snatch.