lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
555 stars 26 forks source link

--x265 option seems to always use CPU encoding #183

Closed octopush-it closed 1 year ago

octopush-it commented 1 year ago

With various 2K rips, when running a normal other-transcode, the encode will fail because the codec isn't supported unless I use the --x265 option. When I do this, even if I try and specify the --nvenc it still uses cpu encoding.

Is this a known limitation with some video/formats? I did try and search issues here before I asked :)

lisamelton commented 1 year ago

@octopush-it I'm sorry you're having a problem but I don't really understand what you mean. Your issue title doesn't really match your description of the issue itself.

I need more information. Please include the command line you're using and either a .log file or the relevant console spew so I can tell what's going on.

Thanks.

octopush-it commented 1 year ago

Sorry - thats what I get for trying to multitask. Here is the issue as it relates to the title. When I run into issues where I either :

  1. Cannot use --mp4 because of multiple subtitle or audio streams
  2. Cannot use the basic "other-transcode" because the file has been X265 encoded already

I have to provide the --x265 option to get the file to process successfully. When I use the --x265 option, however, it never seems to use the GPU for transcoding, even if I use the --nvenc flag. The file will process with the CPU at ~5-10fps. For every other x264 encoded file regardless of container, other-transcode will reliably use the GPU for processing at ~300-600fps.

Here is the output of two recent log runs that failed, and a cap of the encoding output when I get it to process successful, though slowly. other-transcode_--mp4-option_no-other-flags.log other-transcode_--x265-option_lowFPS.log other-transcode_no-options.log

other-transcode--x265--nvenc_out-of-memory.log

GPU is an RTX3070Ti

lisamelton commented 1 year ago

@octopush-it Thanks for the .log files!

You can't use the --mp4 option if you include image-based subtitles because those aren't compatible with the MP4 format. However, that doesn't appear to be the problem with the .log files you've supplied.

The problem is that you're trying to transcode a 10-bit HEVC input to 8-bit H.264 output. That probably won't work and even if it did, the color mapping would likely be wrong.

And when you want HEVC output, pick a single HEVC encoder. Don't put both --x265 and then --nvenc in your options. The last one on the command line will be selected, that being NVenc in .log you included, but other things can go wrong that way.

I have no idea why Nvenc is failing for you. I've never seen that error before.

I see that you are using a development build of ffmpeg. Version N-104488-ga13646639f-20211109 is in the .log file. That's never a good idea. Try downloading a stable release. I recommend version 6.0. That should be the latest.

And if that doesn't work, I recommend you try my newer transcoding project. The four scripts it includes handle 10-bit inputs much better.

You can find it here:

https://github.com/donmelton/more-video-transcoding

It's based on HandBrakeCLI. If you decide to try it, use a stable release of HandBrake and not a nightly development build.

I hope that helps.

octopush-it commented 1 year ago

THanks! Using the nvenc-hevc-transcode produces a different error each time its run, which is weird:

E:\transcode>ruby nvenc-hevc-transcode.rb "temp\x.mkv" nvenc-hevc-transcode.rb: Search timed out SYNTAX_SUGGEST_TIMEOUT=1, run with DEBUG=1 for more infoC:/Ruby32-x64/lib/ruby/3.2.0/syntax_suggest/code_line.rb:119:in empty?' C:/Ruby32-x64/lib/ruby/3.2.0/syntax_suggest/code_line.rb:123:innot_empty?' C:/Ruby32-x64/lib/ruby/3.2.0/syntax_suggest/code_block.rb:68:in `select'nvenc-hevc-transcode.rb:8: syntax error, unexpected '<' (SyntaxError) <!DOCTYPE html> ^

E:\transcode>ruby nvenc-hevc-transcode.rb "temp\x.mkv" nvenc-hevc-transcode.rb: Search timed out SYNTAX_SUGGEST_TIMEOUT=1, run with DEBUG=1 for more infoC:/Ruby32-x64/lib/ruby/3.2.0/syntax_suggest/code_block.rb:89:in join' C:/Ruby32-x64/lib/ruby/3.2.0/syntax_suggest/code_block.rb:89:invalid?' C:/Ruby32-x64/lib/ruby/3.2.0/syntax_suggest/code_search.rb:94:in `push'nvenc-hevc-transcode.rb:8: syntax error, unexpected '<' (SyntaxError) <!DOCTYPE html> ^

E:\transcode>ruby nvenc-hevc-transcode.rb "temp\x.mkv" nvenc-hevc-transcode.rb: Search timed out SYNTAX_SUGGEST_TIMEOUT=1, run with DEBUG=1 for more infoC:/Ruby32-x64/lib/ruby/3.2.0/syntax_suggest/api.rb:118:in hash' C:/Ruby32-x64/lib/ruby/3.2.0/syntax_suggest/api.rb:118:in-' C:/Ruby32-x64/lib/ruby/3.2.0/syntax_suggest/api.rb:118:in `valid_without?'nvenc-hevc-transcode.rb:8: syntax error, unexpected '<' (SyntaxError) <!DOCTYPE html> ^

lisamelton commented 1 year ago

@octopush-it I'm glad you tried nvenc-hevc-transcode.rb! But I have no idea what's going on with those error messages. 🤷‍♀️ It looks like something is wrong with your Ruby runtime?

skj-dev commented 1 year ago

@octopush-it How did you save the file. If you did something like wget https://github.com/donmelton/more-video-transcoding/blob/master/nvenc-hevc-transcode.rb then the GitHub web page for the script is saved, not the script itself.

If that happened, then the error message might make some sense. This is what the first ten lines would look like:

      1
      2
      3
      4
      5
      6
      7
      8 <!DOCTYPE html>
      9 <html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system">
     10   <head>

The error says there's a syntax error at line 8, with an unexpected <. If the above is the actual content of the file, then that seems to line up remarkably well.

To fetch the script you'll need to get the RAW file. This can be done by clicking on the RAW button, and then using that link. For example, wget https://raw.githubusercontent.com/donmelton/more-video-transcoding/master/nvenc-hevc-transcode.rb will fetch the actual script.

Alternatively, you can clone the repo.

This may not be your problem, but the symptom seems to line up, so I thought it was worth a mention.

lisamelton commented 1 year ago

@ttyS0 Oh snap! That's gotta be the problem. 👍 Nice detective work, sir.

lisamelton commented 1 year ago

@octopush-it So, did you try to re-download and re-run the script using @ttyS0 's suggestion?

octopush-it commented 1 year ago

@ttyS0 uuuuunbelievable ... LOL - the simplest things. Its working and I am dumb! Thanks both!

octopush-it commented 1 year ago

@donmelton FYI using nvenc-hevc-transcode has resulted in a significant gain in transcoding over other-transcode with the x265 10bit file... from 10-20fps to 150fps . Amazing!