playerC/ffmpeg_rtppipe
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
FFmepg rtppipe
==============
添加 rtppipe 支持从stdin接收RTP视频数据.
Add rtppipe support to recieve RTP video data from stdin.
Liscense : See LICENSE.md
Copyright (c) 2026 playerc@msn.cn
用法 Usage
==========
如需要把 WebRTC 中的RTP视频流保存成视频文件,在代码中运行一下命令,并
获取到STDIN作为 videoStream.
To save an RTP video stream from WebRTC to a video file, run the
following command in your code and obtain STDIN as the videoStream.
::
ffmpeg -protocol_whitelist rtp,pipe,file,udp -f sdp_pipe \
-reorder_queue_size 9999 -i tests/test.sdp -f flv testr.flv
设置 WebRTC onMessage:
Setup WebRTC onMessage:
::
this.track.onMessage((msg) => {
if (this.startRecord == true){
let rtppipeHead = Buffer.allocUnsafe(6);
rtppipeHead.writeUInt8(0x24, 0);
rtppipeHead.writeUInt8(0, 1);
rtppipeHead.writeUInt16BE(msg.length, 2);
rtppipeHead.writeUInt16BE(0, 4);// not used
this.videoStream.write(rtppipeHead);
this.videoStream.write(msg);
}
});
向 videoStream 发送 EOF 即可结束录制.
Sending EOF to the videoStream will stop the recording.
如何设置SDP文件 How to config SDP file
=======================================
是的,你必须按需修改SDP文件,也就是案例中的 `test.sdp` 文件. 以下是示
例,请按需求修改,使用时请移除注释.
Yes, you must modify the SDP file as needed—in this case, the test.sdp
file. Below is an example; please adjust it according to your
requirements and remove the comments before use.
::
SDP:
v=0
o=- 0 0 IN IP6 ::1
s=No Name
c=IN PIPE6 ::1 /* use rtppipe on localhost */
t=0 0
a=tool:libavformat LIBAVFORMAT_VERSION
m=video 8888 RTP/AVP 96 /* !!! RTP video port. (RTSP use this PORT+1 ) */
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1
如何构建 How to build
=====================
See INSTALL.md
:~ EOF