Skip to content

Publish tracks with different codecs not working #450

Open
@thepacketloss

Description

@thepacketloss

Select which package(s) are affected

@livekit/rtc-node

Describe the bug

when I publish 3 tracks with different codecs all three tracks will publish with the codec of first published track.
I mean consider I want to publish 3 tracks like these :
Track 1 with AV1
Track 2 with VP9
Track 3 with VP8
all 3 tracks will be published with AV1 codec
and if I change the order of publish like this :
Track 1 with VP8
Track 2 with VP9
Track 3 with AV1
then all 3 tracks will be published with VP8 codec.

Image

Reproduction

const room = new Room();
await room.connect('ws://localhost:7880', jwt, {autoSubscribe: true, dynacast: true});

room.on(RoomEvent.TrackSubscribed, async (track, publication, participant) => {
    const source = new VideoSource(1920, 1080);
    const av1_track = LocalVideoTrack.createVideoTrack('av1_track', source);
    const vp9_track = LocalVideoTrack.createVideoTrack('vp9_track', source);
    const vp8_track = LocalVideoTrack.createVideoTrack('vp8_track', source);
    await room.localParticipant.publishTrack(av1_track, {
        simulcast: false,
        videoCodec: VideoCodec.AV1,
        source: TrackSource.SOURCE_SCREENSHARE,
        videoEncoding: {
            maxBitrate: 250_000,
            maxFramerate: 10
        }
    })
    await room.localParticipant.publishTrack(vp9_track, {
        simulcast: false,
        videoCodec: VideoCodec.VP9,
        source: TrackSource.SOURCE_SCREENSHARE,
        videoEncoding: {
            maxBitrate: 250_000,
            maxFramerate: 10
        }
    })
    await room.localParticipant.publishTrack(vp8_track, {
        simulcast: false,
        videoCodec: VideoCodec.VP8,
        source: TrackSource.SOURCE_SCREENSHARE,
        videoEncoding: {
            maxBitrate: 250_000,
            maxFramerate: 10
        }
    })

    const stream = new VideoStream(track);
    for await (const buf of stream) {
        await source.captureFrame(buf.frame);
    }

    await source.close()
    stream.close()
});

Logs

System Info

Binaries:
    Node: 23.9.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 11.2.0 - /usr/bin/npm
    pnpm: 8.15.4 - ~/.local/share/pnpm/pnpm
    bun: 1.1.21 - ~/.bun/bin/bun
  npmPackages:
    @livekit/rtc-node: ^0.13.8 => 0.13.8 
    livekit-server-sdk: ^2.10.2 => 2.10.2

LiveKit server version

latest self hosted version

Severity

blocking all usage of LiveKit

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions