Stream quality problems with simple h264 encoder

Open
#239 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp

Research direction

Start by reading src/stream/video/SnpEncoderVaH264.cpp and comparing its setup with the H264 example in libva-utils. Inspect the attached encoded stream in VLC and trace how successive frames are encoded and decoded. Done means identifying the cause of the accumulating quality loss and documenting or correcting the relevant encoder behavior.

Written by the indexing model from the issue text.

Description

I've written a simple h264 encoder using libva for a screen capture tool. The encoder is set up to create a single IDR frame with only P frames following. I've copied most of the code from the h264 example in libva-utils. I'm facing a problem with image quality of the encoded stream. Errors in the picture seem to accumulate over time and the visual quality deteriorates as more frames are encoded/decoded.

If i understand correctly, the quality should not get worse over time (as long as there are no transmission errors) - the encoder should know about the "reconstruction error" of individual frames and respect them when encoding another. The video I've attached shows a kind of "ghost picture" of past frames which gets more visible over time. I think I might be doing something wrong in my code, however I cannot find out.

The code can be found here:
https://github.com/martin19/snpserver/blob/main/src/stream/video/SnpEncoderVaH264.cpp

A dump of an encoded stream with QP set to constant value of 30 (can be viewed with VLC for example):
https://drive.google.com/file/d/1IdjtmxVxz6KTW8twdLvYodD7vrFhLU-a/view?usp=sharing

(..rgb components are swapped in the stream, so colors are not correct)

Can anyone please help here?

Dominant language
C
Stars
244
Forks
175
Avg merge
9d 7h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from intel/libva-utils

All issues in intel/libva-utils

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.