I have a stream of h.264 data from a remote webcam. If i save it to a file i'm able to play it in VLC (meaning that the data arrives intact).
The final goal is to turn this stream into a virtual webcam. After looking around I found manyCam as a possible solution - therefor i want to serve the h.264 data on a local IP in MP4 format.
Two questions:
first, I'm trying to wrap the h.264 with the mp4 container using ffmpeg (using fluent-ffmpeg npm library that exposes the ffmpeg API to Nodejs).
Everything works well when i'm handling static files (not streams). e.g.`
var ffmpeg = rquire('fluent-ffmpeg')
var readH264 = fs.createReadStream('./vid.h264')
var proc = ffmpeg(readH264).clone().toFormat('mp4').output('./vid.mp4').run()
`
But when I'm trying to feed a stream - it throws an error "ffmpeg exited with code 1: could not write header for output file.."
`
var wrtieMp4 = fs.createWriteStream('./vid.mp4')
var proc = ffmpeg(readH264).clone().toFormat('mp4').output(wrtieMp4).run()`
How can i add it a header..?
Second, I'm a bit confused about the transport layer (rtp, rtsp, etc.). After creating the mp4 stream - wouldn't it be sufficient to serve the stream with MIME type video/mp4? It seem to work fine with static file.
`
let read = fs.createReadStream('./vid.mp4')
let server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-type': "video/mp4"})
read.pipe(res)
}).listen(9000)
`
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…