kevinGodell/mp4frag

hi if i want rtmp to fmp4 stream how can i start

Closed this issue · 4 comments

ex. if i have rtmp://x.x.x.x/live/test
how can i use node.js create fmp4 stream

not work
const ffmpeg = spawn( 'ffmpeg', ['-loglevel', 'quiet', '-probesize', '64', '-analyzeduration', '100000', '-reorder_queue_size', '5', '-rtsp_transport', 'tcp', '-i', 'rtmp://127.0.0.1:1935/live/test', '-an', '-c:v', 'copy', '-f', 'mp4', '-movflags', '+frag_keyframe+empty_moov+default_base_moof', '-metadata', 'title="ip 127.0.0.1"', '-reset_timestamps', '1', 'pipe:1'], { stdio: ['ignore', 'pipe', 'inherit'] } );

Before trying to run this command inside nodejs, run it in the command line. Of course, make sure you have ffmpeg installed. Start with the simplest command with the input and output. Some of those input flags may not apply to rtmp input, I am not sure. I would try something along the lines of ffmpeg -loglevel verbose -i rtmp://127.0.0.1:1935/live/test video.mp4. Ffmpeg is pretty good at guessing the input type and has good default parameters set. If that command can make a playable mp4, then you can start tweaking the flags and customize the video stream. Let me know your results. I am here to help.

const ffmpeg = spawn( 'ffmpeg', ["-i", "rtmp://127.0.0.1/live/test", '-f', 'mp4', '-movflags', '+frag_keyframe+empty_moov+default_base_moof', '-metadata', 'title="ip 127.0.0.1"', '-reset_timestamps', '1', 'pipe:1' ], { stdio: ['ignore', 'pipe', 'inherit'] } );

i try this can work , but my init-pool.mp4 is empty

image

is work , sorry to bother you ,btw do you know how to build Low latency HLS?

Low latency Hls is not easy. The trick is to get the individual mp4 fragments to be as small as possible. If you can get the chunk size to be 1 second duration, it might get down to a 2 second delay at best. This is a limitation of the mp4 container.