openshot-qt icon indicating copy to clipboard operation
openshot-qt copied to clipboard

Allow configuring a custom export target

Open IrishTLR opened this issue 2 years ago • 4 comments

Computer specs OS : Windows 11 CPU : Intel i9-9900K [8C16T] GPU : NVIDIA GFORCE RTX 2080 [Studio Driver v546.01] RAM : 32GB

Describe the new feature: I'm new to OpenShot, having installed it a few days ago. It's a great tool, well done on the work put in to it. After a few hours of learning it's nuances, I came up against the hardware accelleration issues. I've read through most of your git issues relating to GPU encoding/decoding and understand the current situation at a high to mid level.

To understand more about hardware decoding / encoding, I downloaded FFMPEG and played around with some of it's features to test hardware vs software decoding. Needless to say, I'm seeing a huge time saving using my GPU. For example, exporting a video from OpenShot ...

  • CPU [i9-9900K] encoding at around 15 FPS. Admittedly, not yet thread optimised for OpenShot. I MIGHT be able to get this close to -hwaccel auto below, with some tweaking.
  • QSV h.264 / MKV - just fails with a "could not open video codec", although FFMPEG also refuses this.

However, if I run a manual FFMPEG test from the command line [although I did have to install the latest drivers from NVIDIA rather than use the Windows Update ones], I get ...

  • GPU Decode - Software Encode - 30 FPS [ffmpeg -hwaccel auto -i input.mp4 output.mp4]
  • GPU Decode - GPU ENCODE - 100+ FPS [ffmpeg -hwaccel auto -i input.mp4 -c:v h264_nvenc output.mp4]

Describe the solution you'd like: A config/parameter that a user could enter specific FFMPEG encode / decode parameters. I totally understand that there are many variables to a successful hardware de/encode process but would you consider an advanced option where power users can take the risk? For large video exports, it's the difference between an 4 hour export to maybe an hour or less.

Describe alternatives you have considered: At a minimum, would you consider adding an export profile that just enabled -hwaccel auto. This alone would more than half my export time.

I did see this Pull Request (#3232) from 2020 but it doesn't seem to be have been applied yet. It adds some more GPU options but not a custom one.

Looking at the PR above, it appears that there are XML presets for each target. I'm going to try create one to see if it works. However, this wouldn't be ideal as I would then have to manage that file in all upgrades, re-installs etc.

Screenshots: (Optional) CPU Only cpu_only

GPU Decoding / CPU Encoding hwaccel_auto

GPU Only hwaccel_auto_h264

IrishTLR avatar Nov 12 '23 10:11 IrishTLR

Some more thoughts. While I don't intend on moving away from OpenShot, the time to encode is brutally slow.

So a little more investigation into FFMPEG. These options work, even though none of these work for me in OpenShot. ./ffmpeg -y -hwaccel auto -i ./input.mp4 output.mp4 ./ffmpeg -y -hwaccel auto -i ./input.mp4 -c:v h264_nvenc ./output.mp4 ./ffmpeg -y -hwaccel auto -i ./input.mp4 -c:v hevc_nvenc ./output.mp4 ./ffmpeg -y -hwaccel cuda -i ./input.mp4 -c:v hevc_nvenc ./output.mp4 ./ffmpeg -y -hwaccel d3d11va -i ./input.mp4 -c:v hevc_nvenc ./output.mp4

The below two actually do the exact same thing. This would lead me to believe that my CPU doesn't support QuickSync. ./ffmpeg -y -hwaccel_output_format qsv -i ./input.mp4 -c:v hevc_nvenc ./output.mp4 ./ffmpeg -y -i ./input.mp4 -c:v hevc_nvenc ./output.mp4

This doesn't work ./ffmpeg -y -hwaccel qsv -i ./input.mp4 -c:v hevc_nvenc ./output.mp4

I get a deprecation warning... [vist#0:0/h264 @ 000001f59ef7fd80] WARNING: defaulting hwaccel_output_format to qsv for compatibility with old commandlines. This behaviour is DEPRECATED and will be removed in the future. Please explicitly set "-hwaccel_output_format qsv".. That's why I tried the -hwaccel_output_format option above.

And I also get an error [AVHWDeviceContext @ 000001f59efc9d00] Error creating a MFX session: -9. Device creation failed: -1313558101. No device available for decoder: device type qsv needed for codec h264_qsv. [vist#0:0/h264 @ 000001f59ef7fd80] Hardware device setup failed for decoder: Unknown error occurred [vost#0:0/hevc_nvenc @ 000001f59ef762c0] Error initializing a simple filtergraph Error opening output file ./output.mp4. Error opening output files: Unknown error occurred.

I forked the openshot-qt and libopenshot repos to dig into the source code. Having not touched python / cpp in decades, I'm comfortable viewing but not really amending, and certainly don't have a build stack. I wanted to see why my custom presets weren't being used. According to the openshot-qt code src/windows/export.py, info.EXPORT_PRESETS_PATH, info.USER_PRESETS_PATH are both checked for xml files and loaded IF the configured codec is available. However, they aren't loaded nor the expected error generated in the log file.

An example file I created, and tried placing in C:\Program Files\OpenShot Video Editor\presets as well as C:\Users\user\.openshot_qt\presets is attached and is not imported into the export form.

txt extension instead of xml, to allow upload to github. format_mp4_x264_nvenc.txt format_mp4_hevc_nvenc.txt

All things being equal, openshot.FFmpegWriter.IsValidCodec() would appear to be returning FALSE even though my two codecs [hevc_nvenc, h264_nvenc] exist and work with FFMPEG command line.

The performance Tab also appears to have a mind of its own. The test button will pass the test if I set the Max Width/Height to 0. But on a restart will fail the test with no changes made since startup. Setting max width=3840 and max height=2160 will succeed the test again but a restart, going back into Preferences-> Performance, returns a failed test. This is a little odd with no apparent reasoning.

Not sure where to go from here but will continue on trying to get custom presets working.

IrishTLR avatar Nov 12 '23 14:11 IrishTLR

Hello @IrishTLR. Thank you for all this information. The lead developer, @jonoomph, will need to review this and decide how to move forward. I have assigned this ticket to him.

Any additional information you share will be greatly appreciated.

Colorjet3 avatar Nov 12 '23 22:11 Colorjet3

Thank you. I don't want to bother the lead too much. I know hardware encoding is on the roadmap to be revisited at some point. It was more of an investigatory brain dump of my experiences. If I can assist in testing configurations, just let me know. Otherwise you can actually close this if it's too much noise.

IrishTLR avatar Nov 14 '23 08:11 IrishTLR

No bother at all @IrishTLR. I'll keep it open for the developer. He can decide to close it or not.

Colorjet3 avatar Nov 14 '23 22:11 Colorjet3