Open felicemarra opened 3 years ago
I successfully wrote the code to create a mp4 from a raw audio/video source
But if something happens during recording, I loose everything because mp4 is corrupted and unrecoverable.
So I need to write a mkv file but there something wrong with initialization. Can you help me?
I just changed format_name: 'mp4' to format_name: 'matroska' and filename from mp4 to mkv. Note : the original code for mp4 is working well.
` let encParamsVideo = { name: 'h264_nvenc', width: config.width, height: config.height, bit_rate: 20000000, time_base: [1, 30], framerate: [30, 1], gop_size: 60, max_b_frames: 0, pix_fmt: 'yuv420p', }
let encParamsAudio = { name: 'libfdk_aac', time_base: [1, 48000], sample_fmt: 's16', sample_rate: 48000, channels: 1, channel_layout: 'mono', profile: 'LC' } let encoderVideo = await beamcoder.encoder(encParamsVideo) let encoderAudio = await beamcoder.encoder(encParamsAudio) encoderAudio.priv_data = { vbr: 3 } const muxer = beamcoder.muxer({ format_name: 'matroska', tune: 'film' }) muxer.interleaved = false let vstr = muxer.newStream({ name: 'h264_nvenc', time_base: [1, 90000], interleaved: false }) Object.assign(vstr.codecpar, { width: config.width, height: config.height, format: 'yuv420p', bit_rate: 10000000 }) let astr = muxer.newStream({ time_base: [1, 90000], name: 'aac', interleaved: true }) Object.assign(astr.codecpar, { extradata: encoderAudio.extradata, name: 'aac', sample_rate: 48000, format: 'flt', frame_size: 1024, channels: 1, channel_layout: 'mono', bit_rate: 192000 }) await muxer.openIO({ url: 'file:.\\record\\output_' + Date.now() + '.mkv' }) await muxer.writeHeader()
`
I successfully wrote the code to create a mp4 from a raw audio/video source
But if something happens during recording, I loose everything because mp4 is corrupted and unrecoverable.
So I need to write a mkv file but there something wrong with initialization. Can you help me?
I just changed format_name: 'mp4' to format_name: 'matroska' and filename from mp4 to mkv. Note : the original code for mp4 is working well.
` let encParamsVideo = { name: 'h264_nvenc', width: config.width, height: config.height, bit_rate: 20000000, time_base: [1, 30], framerate: [30, 1], gop_size: 60, max_b_frames: 0, pix_fmt: 'yuv420p', }
`