Video quality degradation after upgrading LiveKit libraries
Opened this issue · 5 comments
I tried updating the livekit-agents library and some related libraries (such as livekit, livekit-api, livekit-plugins-deepgram) to their latest versions. Here are the old and new versions:
Old versions:
livekit==0.17.4
livekit-agents==0.10.0
livekit-api==0.6.0
livekit-plugins-deepgram==0.6.7
New versions:
livekit==0.18.2
livekit-agents==0.12.2
livekit-api==0.8.0
livekit-plugins-deepgram==0.6.14
After upgrading, we encountered an issue where the video stream quality deteriorated. The video now has lower resolution and a reduced frame rate.
With the old library versions, the video output was 540x960 resolution at 25 fps, which met our expectations. However, with the new versions, the resolution has dropped to 180x320 and the frame rate to 15 fps. Below is a comparison:
video output | analytics result | |
---|---|---|
old libraries | ||
new libraries |
My application was initially based on this example, but instead of using color, we are publishing video and we are using livekit cloud server.
https://github.com/user-attachments/assets/8f46fddb-f5c0-4a23-916f-cbd2316403f8
Is there a reason for this difference in video quality with the new versions? If so, is there a way to restore the previous resolution and frame rate?
We cannot proceed with the latest version until this is resolved.
Thank you for your help!
@theomonnom could you please help with this?
Hey, we're going to take a look at this this week
@quoctuanck99 are you able to reproduce this with our example apps? and could you share the publish parameters?
@davidzhao Thanks you for your reply. Here is an example code snippet that demonstrates the issue:
import asyncio
import logging
import cv2
from dotenv import load_dotenv
from livekit import rtc
from livekit.agents import JobContext, WorkerOptions, cli
from livekit.rtc import VideoCodec
# Load environment variables
load_dotenv()
WIDTH = 540
HEIGHT = 960
async def entrypoint(job: JobContext):
await job.connect()
room = job.room
source = rtc.VideoSource(WIDTH, HEIGHT)
track = rtc.LocalVideoTrack.create_video_track("single-color", source)
options = rtc.TrackPublishOptions(
source=rtc.TrackSource.SOURCE_CAMERA, video_codec=VideoCodec.VP9
)
publication = await room.local_participant.publish_track(track, options)
logging.info("published track", extra={"track_sid": publication.sid})
video_capture = cv2.VideoCapture("./source.mp4")
async def _publish_video():
argb_frame = bytearray(WIDTH * HEIGHT * 4)
while True:
await asyncio.sleep(0.04) # 100ms
ret, frame = video_capture.read()
if not ret:
video_capture.set(cv2.CAP_PROP_POS_FRAMES, 0)
_, frame = video_capture.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame = rtc.VideoFrame(WIDTH, HEIGHT, rtc.VideoBufferType.RGB24, frame)
source.capture_frame(frame)
await _publish_video()
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
source.mp4
@davidzhao @theomonnom Hi, could you guys have any updates for this?