Skip to content
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

Added NetInt Quadra Support #1539

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Added NetInt Quadra Support #1539

wants to merge 10 commits into from

Conversation

n8o
Copy link

@n8o n8o commented Feb 27, 2024

This PR adds basic support for NetInt Quadra.

  • Added Docker Image
  • Updated docs
  • Tested AVC ABR encoding with 8bit and 10bit content.
  • Decode, Scale, Encode all in hardware

Needs:

  • Tests. Where are the unit tests?
  • Test HEVC encoding and decoding
  • Add JPEG and AV1 Support

@getroot
Copy link
Sponsor Member

getroot commented Feb 29, 2024

Thanks for your contribution. Unfortunately we don't have this device so we can't test it. We have no choice but to rely on contributors for this equipment.

We don't have a unit test template yet, and each developer is doing his own testing.

AV1 cannot be tested because no publisher supports it yet. We will support this for WebRTC in the future.

@nums Could you please review this?

@nums
Copy link
Contributor

nums commented Mar 1, 2024

Yes, I will do a review.

I was also not able to test directly: unfortunately my netint card is a "logan" but not a "quadra"

@nums
Copy link
Contributor

nums commented Mar 1, 2024

hello @n8o , I did a quick check and I noticed this line:
https://github.com/n8o/OvenMediaEngine/blob/master/src/projects/transcoder/codec/encoder/encoder_avc_niquadra.cpp#L78
On the avc side it is commented but you kept it on the hevc.
On the Logan, I had to apply it on both.

It's probably normal but in case it's forgotten after a test...

@n8o
Copy link
Author

n8o commented Mar 1, 2024

What line are you referring to? L7 is a copyright header line. I haven't actually tested HEVC decode and encode. I'll do that today and should be done before merging.

@nums
Copy link
Contributor

nums commented Mar 1, 2024

What line are you referring to? L7 is a copyright header line. I haven't actually tested HEVC decode and encode. I'll do that today and should be done before merging.

sorry, bad copy and paste: https://github.com/n8o/OvenMediaEngine/blob/master/src/projects/transcoder/codec/encoder/encoder_avc_niquadra.cpp#L78

@n8o
Copy link
Author

n8o commented Mar 1, 2024

I should be able to enable that line. I don't think it matters. I believe i disabled it while debugging issues before i got it working. the low latency setting is probably nice for webrtc. not sure if it affects quality or not for ABR HLS.

I believe OME already forces keyframes when they are needed. so the keyframe param may not be needed.
https://github.com/n8o/OvenMediaEngine/blob/59e7368a7494c6b1d7b2c434b70b5715a97fae32/src/projects/transcoder/codec/encoder/encoder_avc_niquadra.cpp#L40

@nums
Copy link
Contributor

nums commented Mar 1, 2024

For the lowdelay parameter I didn't see any difference but I added it just in case, however the gopPresetIdx allowed b-frames to be deactivated. (for the record, it seems to me that the gopPreset is at 4)

@n8o
Copy link
Author

n8o commented Mar 1, 2024

I tried enabling it and got a bunch of errors. Looking at the documentation for quadra it reports:

lowDelay
Specifies whether or not to enable the low latency mode in encoding. When enabled, libxcoder increases its rate of polling the encoder and only permits buffering of a single frame to minimize the delay.

NOTE – That when enabled, the gopPresetIdx must be 1, 3, 7, 9, 10, or 0 with a consecutive order gop pattern, lookaheadDepth must be 0, and multicoreJointMode must be 0.

Supported values for gopPresetIdx are:

-1: Adaptive Gop (default)
0 : Custom Gop
1 : I-I-I-I,..I (all intra, gop_size=1)
3 : I-B-B-B,...B (consecutive B, gop_size=1)
4 : I-B-P-B-P,... (gop_size=2)
5 : I-B-B-B-P,... (gop_size=4)
7 : I-B-B-B-B,... (consecutive B, gop_size=4)
8 : I-B-B-B-B-B-B-B-B,... (random access, gop_size=8) 9 : I-P-P-P,... P (consecutive P, gop_size=1)
10 : I-P-P-P-P,... (hierarchical P, gop_size=4)

So with that, I set it to 1 and 1:
::av_opt_set(_codec_context->priv_data, "xcoder-params", "gopPresetIdx=1:lowDelay=1", 0);

that seems to work.

@n8o
Copy link
Author

n8o commented Mar 5, 2024

Any more changes or requests?

@n8o
Copy link
Author

n8o commented Mar 7, 2024

@nums or @getroot

bump

@nums
Copy link
Contributor

nums commented Mar 7, 2024

Sorry, a little bit busy this week.

@getroot, on my side it's ok and ready to be merge :)

@n8o
Copy link
Author

n8o commented Mar 7, 2024

Actually i just noticed that gopPresetIdx 1 is all i-frames. I need to change that. Either idx 9 or 10?

@nums
Copy link
Contributor

nums commented Mar 7, 2024

@n8o
Copy link
Author

n8o commented Mar 7, 2024

Fixed. Documentation said to use 9 with lowDelay.

Copy link
Contributor

@basisbit basisbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments.

@@ -0,0 +1,45 @@
# Instruction: Build local OvenMediaEngine Dev Environment. Can be used with CLion dev environment as a toolchain
# Information on hot to setup: https://www.jetbrains.com/help/clion/clion-toolchains-in-docker.html#sample-dockerfile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hot to should probably be how to

@@ -0,0 +1,45 @@
# Instruction: Build local OvenMediaEngine Dev Environment. Can be used with CLion dev environment as a toolchain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I am not too fond of having yet another Dcokerfile here which will have to be manually updated each time to keep in sync with the other Dockerfiles and the docker-compose.yml. There already exists the Dockerfile.local for local building and developing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I will merge them and maybe add a comment on how to only do a build image vs release image.
https://docs.docker.com/build/building/multi-stage/

@@ -0,0 +1,111 @@
# Instruction: Build OvenMediaEngine with Netint Quadra support
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having many Dockerfiles, please consider moving anything hardware acceleration specific which is not an environment parameter into one of the misc/prerequisites scripts to keep it easy to get OME running in those environments which are either not using Docker or are not one of the "standard" supported environments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll investigate this


#yasm install
WORKDIR /NI_Release
RUN wget -c http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change this to https, there is no hash / checksum checking here.

cd $NETINT_QUADRA_XCODER_COMPILE_PATH && bash build.sh && ldconfig #the compilation of libxcoder can be done before
fi
ADDI_LIBS+=" --enable-ni_quadra --enable-avfilter --enable-pthreads "
ADDI_ENCODER+=",h264_ni_quadra,h265_ni_quadra"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the license implications of this? Is releasing a pre-built docker container with this compliant wit AGPL?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about licensing and how this works for AGPL. wouldn't this be the same as all the others? Nvidia driver is proprietary. so is the logan and quadra. OME uses it through ffmpeg which is compiled with nvidia and netint support. i do believe the one header file that ffmpeg uses for nvidia is open source. but everything else is close source. I'm not affiliated with netint. so i'm not sure

I just assumed since you already had logan support that quadra would be fine. this section is basically just a copy of how logan's prerequisites work..

switch (input_module_id)
{
case cmn::MediaCodecModuleId::NIQUADRA: { // Zero Copy
//TODO: Exception handling required if Device ID is different.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please finish this before merging, thanks


output_track->SetColorspace(encoder->GetSupportedFormat());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this indentation change on purpose? If not, please revert

@basisbit
Copy link
Contributor

basisbit commented Mar 8, 2024

Also, might be worth it to update this PR to ffmpeg 6 or newer

@getroot
Copy link
Sponsor Member

getroot commented Mar 8, 2024

Also, might be worth it to update this PR to ffmpeg 6 or newer

ffmpeg 6 will take some time for us.

Copy link

stale bot commented May 8, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 8, 2024
@getroot getroot removed the stale label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants