shutter-encoder icon indicating copy to clipboard operation
shutter-encoder copied to clipboard

H.264 encode doesn't automatically choose appropriate profile level and throws error

Open will-neithan opened this issue 1 year ago • 2 comments

Hello,

I have a .mkv H.264 NVENC file recorded in OBS with 223000 constant bitrate with automatically assigned High 5.1 profile. When I want to reencode this file in Shutter Encoder to .mp4 with the same parameters H.264 NVENC 223000 CBR, it throws error. When I force profile to Main 6.1 reencode finishes successfully. I know that the maximum bitrate for levels 5.1, 5.2, 6 is 240000 kbps, so that would be my guess, that it is too close and it is a problem. Nevertheless, I guess the app should be able to handle it automatically. I tried the same reencode in Handbrake and it automatically adjusted to Main 6.1. Thank you for your work.

-hwaccel auto -strict -2 -v quiet -hide_banner -ss 0ms -i "C:\Users\ADAM\Documents\Adam\Projects\Streams\OBS Recording Editing Lag\sources\nfs_cbr_223k_obs-rec-mkv.mkv" -filter_complex "[0:v]scale=684:384:sws_flags=bilinear:sws_dither=none[v];[0:a:0]showvolume=f=0:w=684:h=4:t=0:b=0:v=0:o=v:s=0:p=0.5[volume];[v][volume]overlay=W-w:H-h" -r 60.0 -c:v bmp -an -f image2pipe -
Input #0, lavfi, from 'nullsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (h264_nvenc))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf61.9.101
  Stream #0:0: Video: h264 (Main), yuv420p(tv, progressive), 640x360 [SAR 3:4 DAR 4:3], q=2-31, 2000 kb/s, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc61.28.100 h264_nvenc
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
[out#0/null @ 000001f946b53a40] video:1KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown
frame=   25 fps=0.0 q=12.0 Lsize=N/A time=00:00:00.88 bitrate=N/A speed=2.99x    

Input #0, lavfi, from 'nullsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (h264_qsv))
Press [q] to stop, [?] for help
[h264_qsv @ 0000019f8a576340] Error initializing a MFX session: unsupported (-3)
[h264_qsv @ 0000019f8a576340] The current mfx implementation is not supported, try next mfx implementation.
 -hwaccel auto -strict -2 -v quiet -hide_banner -ss 0ms -i "C:\Users\ADAM\Documents\Adam\Projects\Streams\OBS Recording Editing Lag\sources\nfs_cbr_223k_obs-rec-mkv.mkv" -filter_complex "[0:v]scale=1256:704:sws_flags=bilinear:sws_dither=none[v];[0:a:0]showvolume=f=0:w=1256:h=7:t=0:b=0:v=0:o=v:s=0:p=0.5[volume];[v][volume]overlay=W-w:H-h" -r 60.0 -c:v bmp -an -f image2pipe -
[h264_qsv @ 0000019f8a576340] Error initializing a MFX session: unsupported (-3)
[vost#0:0/h264_qsv @ 0000019f8a5546c0] [enc:h264_qsv @ 0000019f8a550400] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[vf#0:0 @ 0000019f8a576f80] Error sending frames to consumers: Function not implemented
[vf#0:0 @ 0000019f8a576f80] Task finished with error code: -40 (Function not implemented)
[vf#0:0 @ 0000019f8a576f80] Terminating thread with return code -40 (Function not implemented)
[vost#0:0/h264_qsv @ 0000019f8a5546c0] [enc:h264_qsv @ 0000019f8a550400] Could not open encoder before EOF
[vost#0:0/h264_qsv @ 0000019f8a5546c0] Task finished with error code: -22 (Invalid argument)
[vost#0:0/h264_qsv @ 0000019f8a5546c0] Terminating thread with return code -22 (Invalid argument)
[out#0/null @ 0000019f8a553cc0] Nothing was written into output file, because at least one of its streams received no packets.
frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/A    
Conversion failed!

Input #0, lavfi, from 'nullsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (h264_amf))
Press [q] to stop, [?] for help
[h264_amf @ 0000014f665e6700] CreateComponent(AMFVideoEncoderVCE_AVC) failed with error 13
[vost#0:0/h264_amf @ 0000014f665c46c0] [enc:h264_amf @ 0000014f665bfbc0] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[vf#0:0 @ 0000014f665e6940] Error sending frames to consumers: Encoder not found
[vf#0:0 @ 0000014f665e6940] Task finished with error code: -1129203192 (Encoder not found)
[vf#0:0 @ 0000014f665e6940] Terminating thread with return code -1129203192 (Encoder not found)
[vost#0:0/h264_amf @ 0000014f665c46c0] [enc:h264_amf @ 0000014f665bfbc0] Could not open encoder before EOF
[vost#0:0/h264_amf @ 0000014f665c46c0] Task finished with error code: -22 (Invalid argument)
[vost#0:0/h264_amf @ 0000014f665c46c0] Terminating thread with return code -22 (Invalid argument)
[out#0/null @ 0000014f665c3f00] Nothing was written into output file, because at least one of its streams received no packets.
frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/A    
Conversion failed!

Input #0, lavfi, from 'nullsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (h264_vulkan))
Press [q] to stop, [?] for help
[h264_vulkan @ 0000014a6a01f440] No rate control settings specified, using fixed QP = 18
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf61.9.101
  Stream #0:0: Video: h264 (High), vulkan(progressive), 320x240 [SAR 1:1 DAR 4:3], q=2-31, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc61.28.100 h264_vulkan
[out#0/null @ 0000014a69fe8900] video:1KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown
frame=   25 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.96 bitrate=N/A speed=34.6x    


Command: -strict -2 -hide_banner -threads 0 -hwaccel auto -i "C:\Users\ADAM\Documents\Adam\Projects\Streams\OBS Recording Editing Lag\sources\nfs_cbr_223k_obs-rec-mkv.mkv" -c:v h264_nvenc -b_ref_mode 0 -b:v 222993k -rc cbr -preset p7 -profile:v high -level 5.1 -map v:0 -c:a aac -ar 48k -b:a 320k -map a:0 -pix_fmt yuv420p -x264opts nal-hrd=cbr:force-cfr=1 -minrate 222993k -maxrate 222993k -bufsize 445986k -sws_flags bicubic -metadata creation_time="2025-02-01T00:25:27.309275500Z" -y "C:\Users\ADAM\Documents\Adam\Projects\Streams\OBS Recording Editing Lag\sources\nfs_cbr_223k_obs-rec-mkv_shutter.mp4"
Input #0, matroska,webm, from 'C:\Users\ADAM\Documents\Adam\Projects\Streams\OBS Recording Editing Lag\sources\nfs_cbr_223k_obs-rec-mkv.mkv':
  Metadata:
    ENCODER         : Lavf60.3.100
  Duration: 00:00:50.20, start: 0.000000, bitrate: 226094 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn (default)
    Metadata:
      DURATION        : 00:00:50.204000000
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Track1
      DURATION        : 00:00:50.155000000
[vist#0:0/h264 @ 000002821c6c0e00] [dec:h264 @ 000002821b1af680] Using auto hwaccel type dxva2 with new default device.
[out#0/mp4 @ 000002821b4b6e80] Codec AVOption x264opts (x264 options) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some decoder which was not actually used for any stream.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[h264_nvenc @ 000002821bd71240] InitializeEncoder failed: invalid param (8): Invalid Level.
[vost#0:0/h264_nvenc @ 000002821be35a80] [enc:h264_nvenc @ 00000282195b4600] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[vf#0:0 @ 000002821bd71600] Error sending frames to consumers: Invalid argument
[vf#0:0 @ 000002821bd71600] Task finished with error code: -22 (Invalid argument)
[vf#0:0 @ 000002821bd71600] Terminating thread with return code -22 (Invalid argument)
[vost#0:0/h264_nvenc @ 000002821be35a80] [enc:h264_nvenc @ 00000282195b4600] Could not open encoder before EOF
[vost#0:0/h264_nvenc @ 000002821be35a80] Task finished with error code: -22 (Invalid argument)
[vost#0:0/h264_nvenc @ 000002821be35a80] Terminating thread with return code -22 (Invalid argument)
[out#0/mp4 @ 000002821b4b6e80] Nothing was written into output file, because at least one of its streams received no packets.
frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/A    
[aac @ 000002821b4a6300] Qavg: 63414.820
Conversion failed!

will-neithan avatar Feb 01 '25 00:02 will-neithan

Thanks I'm correcting this for the next release.

Paul.

paulpacifico avatar Feb 01 '25 08:02 paulpacifico

Hello, any update? I got the same error trying to convert a mov file to webm VP9 keeping alpha layer. But I don't think it's the video content itself, probably has to do with the audio track somehow.

Here's the scenario: 3 videos. Same frames on the video side but different audio track. Length about 1 second (it's a transition). 2 converted just fine, 1 failed.

Error:

[aost#0:1/libopus @ 00000188485c0840] [enc:libopus @ 0000018844576900] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[af#0:1 @ 00000188485c0c40] Error sending frames to consumers: Invalid argument

Verbose console log:

-strict -2 -v quiet -hide_banner -ss 0ms -i "C:\Users\User\video.mov" -filter_complex "[0:v]scale=684:384:sws_flags=bilinear:sws_dither=none,split=2[bg][fg];[bg]drawbox=c=0x202024:replace=1:t=fill[bg];[bg][fg]overlay=0:0,format=rgb24[v];[0:a:0]showvolume=f=0:w=684:h=4:t=0:b=0:v=0:o=v:s=0:p=0.5[volume];[v][volume]overlay=W-w:H-h" -r 60.0 -c:v bmp -an -f image2pipe - Input #0, lavfi, from 'nullsrc': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: wrapped_avframe, yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn Stream mapping: Stream #0:0 -> #0:0 (wrapped_avframe (native) -> vp9 (vp9_qsv)) Press [q] to stop, [?] for help [vp9_qsv @ 000002422a7d1e80] Error initializing a MFX session: unsupported (-3) [vp9_qsv @ 000002422a7d1e80] The current mfx implementation is not supported, try next mfx implementation. [vp9_qsv @ 000002422a7d1e80] Error initializing a MFX session: unsupported (-3) [vost#0:0/vp9_qsv @ 000002422a7b10c0] [enc:vp9_qsv @ 000002422a7ad280] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height. [vf#0:0 @ 000002422a7d2b00] Error sending frames to consumers: Function not implemented [vf#0:0 @ 000002422a7d2b00] Task finished with error code: -40 (Function not implemented) [vf#0:0 @ 000002422a7d2b00] Terminating thread with return code -40 (Function not implemented) [vost#0:0/vp9_qsv @ 000002422a7b10c0] [enc:vp9_qsv @ 000002422a7ad280] Could not open encoder before EOF [vost#0:0/vp9_qsv @ 000002422a7b10c0] Task finished with error code: -22 (Invalid argument) [vost#0:0/vp9_qsv @ 000002422a7b10c0] Terminating thread with return code -22 (Invalid argument) [out#0/null @ 000002422a7b0f80] Nothing was written into output file, because at least one of its streams received no packets. frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A Conversion failed!

P.S. in the end, as a workaround I've used the working webm and replaced the audio. Maybe something borked during the conversion.

bel57 avatar Mar 24 '25 23:03 bel57