I am using livekit room-compostite egress( with a ...
# ask-ai
f
I am using livekit room-compostite egress( with a user participant, agent participant, egress participant ) to write HLS stream to GCP object store. Whenever I rejoin a same room again the new egress agent is overwriting the existing recording( since, its the same basepath ) and I can only see the recording for second rejoin. How to avoid this? Is there a configuration to not overwrite but append!? go sdk config SegmentOutputs: []*livekit.SegmentedFileOutput{ { FilenamePrefix: fmt.Sprintf("call/egress/%s/chunk-%d", roomName, currentTime), FilenameSuffix: livekit.SegmentedFileSuffix_INDEX, SegmentDuration: 6, Protocol: livekit.SegmentedFileProtocol_HLS_PROTOCOL, PlaylistName: "hq.m3u8", Output: &livekit.SegmentedFileOutput_Gcp{ Gcp: &livekit.GCPUpload{ Bucket: "livekitstore", Credentials: string(l.GcsCredentials), }, }, }, },
t
Thanks for reaching out, Tushar. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just a heads-up: LiveKit doesn’t support appending to existing recordings in GCP object storage. But don’t worry—you can easily avoid overwriting by making sure your
FilenamePrefix
or
filepath
includes dynamic placeholders like
{time}
or
{utc}
. These little helpers create unique filenames for each session, so your recordings stay safe and sound. For example, you might want to tweak your
FilenamePrefix
to add a timestamp like this:
Copy code
FilenamePrefix: fmt.Sprintf("call/egress/%s/chunk-{time}", roomName)
This way, each session gets its own unique file based on when it was recorded. If you want, I’m here to help you set it up or answer any other questions you have! Sources: README.md | livekit-protocol/livekit/protocol/egress.pyi | livekit/livekit_egress.pb.go
f
yes, that is correct but it still doesn't solves my problem because the .m3u8 file is getting overwrited with the seconds egress, hence, it doesn't have the chunks from the first egress!
t
To make sure your
.m3u8
playlist file doesn’t get overwritten during HLS egress, it’s a good idea to give each egress session its own unique playlist name. You can do this by setting the
playlist_name
field dynamically with something unique like timestamps or UUIDs. For example, you could tweak your configuration to add a timestamp to the playlist name like this:
Copy code
PlaylistName: fmt.Sprintf("playlists/%s/live-%d.m3u8", roomName, currentTime)
This way, each session gets its own unique playlist file, so you won’t have to worry about overwriting. You might also consider using separate directories or prefixes for each session to keep things extra organized. If you want, I’m here to help you set this up! Sources: Egress API | LiveKit Docs | pkg/pipeline/sink/segments.go | protobufs/livekit_egress.proto | Recording agent sessions | LiveKit Docs | egress/recording_agent.py
f
In that case, How does a client who will be trying to play all the playlists one by one will be able to handle it? What is the standard way to handle a list of .m3h8 playlists
t
Hey there! While LiveKit doesn’t have built-in support for managing or playing multiple
.m3u8
playlists one after the other, you can definitely handle this on your end with a simple approach: 1. Start separate egress jobs for each recording session. 2. Once each job finishes, grab the
playlist_location
from the
EgressInfo
response. 3. Use an HLS player like
hls.js
for web or
AVPlayer
on iOS that supports playlist chaining. You can listen for the player’s
ended
event to trigger the next playlist URL when the current one wraps up. 4. If you want to get fancy, you can also process the manifest files (if that’s enabled) to pull all the segment URLs and timestamps. Then, create a combined playlist by stitching together segments from different egress jobs in timestamp order. This way, you’ll be able to smoothly manage and play multiple playlists without a hitch. If you want a hand setting this up or have any questions, just let me know—I’m happy to help! Sources: Egress API | LiveKit Docs | pkg/config/output_segment.go | Egress API | LiveKit Docs