CESNET / UltraGrid

UltraGrid low-latency audio and video network transmission system
http://www.ultragrid.cz
Other
492 stars 53 forks source link

B frames question #214

Closed TheSashmo closed 2 years ago

TheSashmo commented 2 years ago

I am not able to find any option to introduce B frames into the video. Yes I know it will add latency, but does anyone have an example command?

alatteri commented 2 years ago

what codec and encoder?

TheSashmo commented 2 years ago

libav h.264

alatteri commented 2 years ago

These are the options I see in x264

- weightb - Weighted prediction for B-frames.
- weightp - Weighted prediction analysis method.
    * none
    * simple
    * smart

    - b-bias - Influences how often B-frames are used
- b-pyramid - Keep some B-frames as references.
    * none
    * strict - Strictly hierarchical pyramid
    * normal - Non-strict (not Blu-ray compatible)
- b_strategy - Strategy to choose between I/P/B-frames
TheSashmo commented 2 years ago

Yeah I see those same options, Normally it's a "count" of frames to add. None of those really make sense.

MartinPulec commented 2 years ago

It is intentionally set to zero in UG code. The point is that enabling B-frames isn't just matter of latency but unfortunately also frame timing.

TheSashmo commented 2 years ago

Well I guess that makes sense. Considering B frames are only really needed in high motion low bitrate signals.

I am not 100% sure on your timing statement, but I wont disagree with you. Thanks Martin.

MartinPulec commented 2 years ago

You can try to change it if you wish but we have discussed this internally and we perhaps don't want this neither as an option because from the reasons above it is potentially harmful.

The timing problem is meant that UltraGrid decodes and displays frames as they arrive (roughly speaking) but consider that comes B frame - obviously nothing could be displayed right now and then P frame. Passing the 'P' frame to decoder causes 2 images to be output at the same time - what should display do with it? Either display one and discard the other, or add it to queue - that would possibly work for "synced" display like DeckLink but not eg. for GL with nominal frame rate eg. 60 and video 30, because there will those 2 frames be presented not with 1/30 s delay but 1/60... and then on the other hand gap - this would lead to twitching I think.

The above could be cured by deploying an explicit queue that delays and manages the timing of video frame delivery, but it isn't the case how (now) UG behaves and this is the reason why B-frames are quite unsuitable for UG.