Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Matroska audio/video from raw data #72

Open
felicemarra opened this issue May 17, 2021 · 0 comments
Open

Create Matroska audio/video from raw data #72

felicemarra opened this issue May 17, 2021 · 0 comments

Comments

@felicemarra
Copy link

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()

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant