Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
cybermind

prboom+ -viddump GPU hardware encoding

Recommended Posts

Hi there, haven't found if somebody did that already before me.

I've managed to use NVIDIA hardware encoding for -viddump command. Hope this guide will be helpful to somebody.

Here is how:

(0). Ensure that your prboom+ configuration is able to run -viddump command properly (download oggenc2, mkvmerge etc)
1. Download latest ffmpeg here: https://www.ffmpeg.org
2. Place ffmpeg.exe to prboom+ directory.
3. Open your gl(pr)boom-plus.cfg configuration file.
4. Modify cap_videocommand line to this:

cap_videocommand          "ffmpeg -y -an  -f rawvideo -pixel_format rgb24 -video_size %wx%h -framerate %r -i - -c:v h264_nvenc -preset llhp -rc:v cbr -cq:v 16 -bf:v 3 -b:v 6M -maxrate:v 8M -profile:v main -bufsize:v 8M output.mp4"

(4.1). Customize it to your needs (e.g. change encoder to hevc_nvenc, increase bitrate, I'm not a big expert in ffmpeg encoding commands)

5. Save it.
6. Run your demo file: gl(pr)boom-plus.exe -viddump test.mp4 -timedemo demo.lmp

On my notebook (Asus TUF Gaming FX505DT, Ryzen 5 3550H, NVIDIA GTX 1650) hardware encoding takes more than 2 times less time compared to CPU encoding with x264.exe

Tested with glboom-plus.exe -timedemo lv23-208.lmp, 60 fps, 1280x720: GPU - 73.3 fps, CPU - 31.3 fps.

Share this post


Link to post

I have tried exactly your settings and even placed an ffmpeg.exe file in combination with its "requires" .dll files. However, I cannot export a file in this case. The only thing that happens here is that the demo is being played extremely fast as you can hear its music and sound effects syncing with it. Do you have a solution for that issue?

Share this post


Link to post
On 1/5/2020 at 10:29 PM, cybermind said:

Hi there, haven't found if somebody did that already before me.

I've managed to use NVIDIA hardware encoding for -viddump command. Hope this guide will be helpful to somebody.

Here is how:

(0). Ensure that your prboom+ configuration is able to run -viddump command properly (download oggenc2, mkvmerge etc)
1. Download latest ffmpeg here: https://www.ffmpeg.org
2. Place ffmpeg.exe to prboom+ directory.
3. Open your gl(pr)boom-plus.cfg configuration file.
4. Modify cap_videocommand line to this:


cap_videocommand          "ffmpeg -y -an  -f rawvideo -pixel_format rgb24 -video_size %wx%h -framerate %r -i - -c:v h264_nvenc -preset llhp -rc:v cbr -cq:v 16 -bf:v 3 -b:v 6M -maxrate:v 8M -profile:v main -bufsize:v 8M output.mp4"

(4.1). Customize it to your needs (e.g. change encoder to hevc_nvenc, increase bitrate, I'm not a big expert in ffmpeg encoding commands)

5. Save it.
6. Run your demo file: gl(pr)boom-plus.exe -viddump test.mp4 -timedemo demo.lmp

On my notebook (Asus TUF Gaming FX505DT, Ryzen 5 3550H, NVIDIA GTX 1650) hardware encoding takes more than 2 times less time compared to CPU encoding with x264.exe

Tested with glboom-plus.exe -timedemo lv23-208.lmp, 60 fps, 1280x720: GPU - 73.3 fps, CPU - 31.3 fps.

I've been using NVIDIA hardware encoding with FFMPEG as well.

cap_videocommand          "ffmpeg -y -f rawvideo -pix_fmt rgb24 -s %wx%h -r %r -i pipe:0 -g 480 -c:v hevc_nvenc -preset 1 -level:v 153 -rc:v 32 -rc-lookahead 30 -no-scenecut 1 -cq 28 output.mp4"

Here's the breakdown of the options I used.

-g 480:  Modified key-frame interval.  1 key frame every 8 seconds.

-preset 1:  slow. Although I can probably use the default of 2.

-level:v 153:  Constrains the encoder to not exceed certain values. Level 5.1 is the minimum required for 3840x2160@60fps.  The default main tier constrains the maximum bit-rate to 40M

-rc:v 32:  vbr_hq. Probably not needed and may make the encoder take slightly longer.  Doesn't affect speed at all when using PrBoom software renderer in 4k.

-rc-lookahead 30:  Causes the encoder to build a 1/2 second frame buffer to help smooth out bit-rate spikes. You may notice when starting a demo that it plays super fast for a few frames before slowing down for the rest of the run.

-no-scenecut 1:  When lookahead is enabled, set this to 1 to disable adaptive I-frame insertion at scene cuts (default false).  'Nuff said.

-cq 28:  Constant Quality Mode. The most important factor in determining overall quality.  Keeps the bit-rate somewhat constant while dynamically adjusting the Constant quantization parameter or -qp.  Setting -qp 28 would keep CQ constant while dynamically adjusting the bit-rate.  For streaming it's better to have smooth bit-rate. YouTube will re-encode whatever you feed it anyway, but I like to stream my videos from my private server as well.

 

You'll find I don't specify any kind of bit-rate. Constant Quality mode uses a lot of complex math to determine bit-rate.

 

The resulting output file will have a bit-rate of between 28M and 32M on average.  A one minute long test file came out to about 25MB. These are perfect for uploading to YouTube.  This gives the "YouTube compression algorithm" an excellent starting point to trans-code into a number of picture sizes and formats.  The most common format is VP9.  A 4k file will force YouTube to use VP9 by default and trans-code to about 27M. Eventually AV1 will replace VP9 when hardware decoders become more common.  AV1 promises even better bandwidth savings when it comes to ultra high definition.

 

Also, hevc_nvenc only works with GeForce 900 series or newer.  Playing a 4K HEVC file in VLC or MPC may cause it to appear corrupted or play out of sync.  It does for me on my laptop anyway.  It plays perfectly fine on my desktop.

 

A test encode in glboom-plus at 3840x2160 results in about 38 fps.  In prboom-plus with its advanced pixel smoothing filter maxed out results in about 3 fps.

 

For anyone interested I have made a scripted workflow to get consistent results.

DemoConversion.7z

Edited by L0l1nd3r : A note about youtube reencoding.

Share this post


Link to post
On 12/5/2020 at 10:15 AM, CrazyDoomguy said:

Where is ffmpeg.exe? Cant find in download file

You can start at ffmpeg.org. Current builds for windows can be found at https://www.gyan.dev/ffmpeg/builds/

Scroll down to the release section to find the current builds. I reccomend ffmpeg-release-essentials.7z.  Extract ffmpeg.exe into your prboom directory.

Share this post


Link to post
On 6/15/2020 at 10:22 AM, Dimon12321 said:

I'm curious if it works with AMD graphics. What to write in the codec setting instead of "-c:v h264_nvenc" ?

"-h encoder=h264" will describe all the possible encoders for the H.264 codec. For AMD, you'll want h264_amf

Share this post


Link to post

@chungy, wow! Thank you very much. Now, -viddump works at 55 fps instead of laggy 10-13.

I faced a different problem now. I want to upscale my video to 2160p to make YT compress it at higher bitrate than for 1080p.

What's wrong with this? 

Spoiler

 

GLBoom's config for encoding looks like this:

cap_videocommand          "ffmpeg -f rawvideo -pix_fmt rgb24 -r %r -s %wx%h -i - -c:v h264_amf -b:v 75M -y temp_v.nut"

 

image.png.6e999f4e23c388024f2c55544638b31c.png

 

Thanks!

UPD: looks like upscaling doesn't work using h264_amf at all. XMedia Recode just crashes if I try to process a video using H.264 AMD AMF as codec

Edited by Dimon12321

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×