Reputation: 7044
I have a raw h264 file that I can display with VLC, on a mac:
open -a VLC file.h264
I can convert this to mp4 with the command line
ffmpeg -f h264 -i file.h264 -c:v copy file.mp4
But what I really want to do is something like:
cat file.h264 | ffmpeg > file.mp4
Reason being that the input is coming over a socket and I want to convert it and send it to a video tag in an html file on the fly.
An alternative solution would be a way to display the raw h264 in a web page without converting it to mp4 first.
The input is coming in frame by frame, the first four bytes are 0,0,0,1. My understanding is that this h264 Annex B format.
I know nothing about video formats, I would grateful to be pointed in a direction to look.
Should I look into writing code using libavcodec like this quuesion or is there an off-the-shelf solution?
H.264 muxed to MP4 using libavformat not playing back
Thanks!
Upvotes: 6
Views: 8000
Reputation: 8244
The command line below will create a fragmented MP4 (Windows cmd)
type test.h264 | ffmpeg -i - -vcodec copy -f mp4 -movflags frag_keyframe+empty_moov pipe:1 > test_frag.mp4
You should be able to find lot's of JavaScript code to play fragmented MP4s.
For example: https://github.com/chriswiggins/videojs-fmp4
Upvotes: 8