Код записи, который нужно изменить:
Код: Выделить всё
export class FFmpeg {
private _recordInfo: RecordInfo;
private _process: ChildProcessWithoutNullStreams | undefined;
private _observer: EventEmitter;
constructor(recordInfo: RecordInfo) {
this._recordInfo = recordInfo;
this._process = undefined;
this._observer = new EventEmitter();
this._createProcess();
}
private _createProcess() {
const sdpString = createSdpText(this._recordInfo);
const sdpStream = convertStringToStream(sdpString);
this._process = child_process.spawn("ffmpeg", this._commandArgs);
sdpStream.pipe(this._process.stdin);
}
public kill () {
if (!this._process) return;
this._process.kill('SIGINT');
}
private get _commandArgs() {
let filePath = `${RECORDINGS_FOLDER}/${this._recordInfo.folderName}/playlist`;
let commandArgs = [
"-loglevel", "warning",
"-protocol_whitelist", "pipe,udp,rtp",
"-fflags", "+genpts+discardcorrupt+igndts+nobuffer",
"-flags", "low_delay",
"-analyzeduration", "0",
"-probesize", "32",
"-rw_timeout", "0",
"-timeout", "0",
"-max_delay", "0",
"-f", "sdp",
"-i", "pipe:0",
"-r", "30",
"-map", "0:v:0",
"-c:v", "libx264",
"-preset", "ultrafast",
"-tune", "zerolatency",
"-b:v", "1500k",
"-level:v", "4.1",
"-pix_fmt", "yuv420p",
"-g", "30",
];
commandArgs = commandArgs.concat([
"-movflags", "+frag_keyframe+empty_moov",
"-f", "hls",
"-hls_time", "4",
"-hls_list_size", "0",
"-hls_flags", "independent_segments",
`${filePath}.m3u8`
]);
return commandArgs;
}
};
>
Подробнее здесь: https://stackoverflow.com/questions/798 ... -recording