-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
encode2 (old) FFmpeg API affecting encoder latency #131
Comments
Above is only important for low-latency streaming (real-time) |
Checking if you are affectedThe easiest way is to dump number or ready packets waiting when FFmpeg asks for packet. Add Before popping next packet: Line 431 in 2006718
You will see how much packets are pending
|
Side EffectsThe fact that we are lagging a few packets behind makes #130 non-fatal There is concurrency issue but it generally affects fresh data. We are typically working on data lagging a few packets behind |
WorkaroundsDecrease ffmpeg-jetson -num_capture_buffers <int> E..V..... Number of buffers in the capture context (from 1 to 32) (default 10) This limits the number of pending packets possible In L4T 5.1 with AGX Orin lowest safe value is 4 (see below). BewareNvidia nvmpi doesn't respect all values. In L4T 5.1 with AGX Orin requesting anything <= 3 results in ctx->enc->capture_plane.getNumBuffers() = 3 ctx->enc->output_plane.getNumBuffers() = 4 You can check what happens for you by adding
Line 341 in 2006718
Side Effectsjetson-ffmpeg
When nvidia-nvmpi doesn't respect your request
ExploitSetting
You will:
|
Improving Latency (sane way)Implement jetson-ffmpeg with new FFmpeg API
Which allows easily getting any pending packets (multiple packets per frame) This task is non-trivial. |
- FFmpeg patch with new API implementation - see patch for the details Related to: - jocover#131
- FFmpeg patch with new API implementation - see patch for the details Fix for: - jocover#131
Functional fix is in #132
It has other drawback - may miss last few packets in case of EOS. Choose your poison. |
No need to choose poison) I have added some measures to prevent packet loss |
Your EOS handling looks reasonable Looks like you ventured as far as to Nvidia V4L2 extensions docs
Or guessed it from their 2500 lines lump of code "example"
Anyway, your implementation looks like the one most ahead now
|
Short Description
FFmpeg introduced "new" API around 2016
The old API (
encode2
) generally can return only single packet per-frame (unless draining).Cold encoder init may take a lot of time (100 ms order).
By the time we get first packet from encoder:
The text was updated successfully, but these errors were encountered: