Videos: format=nv12 filter is required to transcode 10bit videos with Intel QSV #2133

Closed
opened 2026-02-20 01:06:51 -05:00 by deekerman · 5 comments
Owner

Originally created by @hicasper on GitHub (Jul 6, 2024).

Originally assigned to: @hicasper on GitHub.

What is not working as documented?

Hardware transcoding can't transcoding iPhone 12 Pro's recording videos. ffmpeg encoder fallback to libh264 from h264_qsv

Video metadata and trace log:

Metadata:
    compatible_brands: qt  
    major_brand     : qt  
    minor_version   : 0
    com.apple.quicktime.location.accuracy.horizontal: 2000.000000
    com.apple.quicktime.make: Apple
    com.apple.quicktime.model: iPhone 12 Pro
    com.apple.quicktime.software: 16.3
    encoder         : Lavf59.27.100
  Duration: 00:01:06.76, start: 0.000000, bitrate: 9810 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main 10) (hvc1 / 0x31637668), yuv420p10le(tv, bt2020nc/bt2020/arib-std-b67), 1920x1080 [SAR 1:1 DAR 16:9], 9627 kb/s, 30 fps, 30 tbr, 90k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 178 kb/s (default)
    Metadata:
      handler_name    : Stereo
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (hevc_qsv) -> h264 (h264_qsv))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))

[h264_qsv @ 0x5f6b7e068880] Current pixel format is unsupported
[h264_qsv @ 0x5f6b7e068880] some encoding parameters are not supported by the QSV runtime. Please double check the input parameters.
[vost#0:0/h264_qsv @ 0x5f6b7e0e3400] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
Error while filtering: Function not implemented
[hevc_qsv @ 0x5f6b7e13d7c0] A decode call did not consume any data: expect more data at input (-10)
    Last message repeated 2 times
[out#0/mp4 @ 0x5f6b7e0811c0] 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=       0kB time=00:00:00.04 bitrate=   0.0kbits/s speed=1.01x    
[aac @ 0x5f6b7e0bfb80] Qavg: 18036.307
Conversion failed!

What could be the cause of your problem?

FFmpeg intel_qsv encoder not support h264 10bit input, so github.com/photoprism/photoprism@7346dd64d7/internal/ffmpeg/config.go (L21) the end of the scale_qsv parameter should add :format=nv12.

I have tested it and it works.

Which software versions do you use?

Photoprism 240531 amd64 docker

On what kind of device is PhotoPrism installed?

Intel N100 with Alder Lake N Graphics

Originally created by @hicasper on GitHub (Jul 6, 2024). Originally assigned to: @hicasper on GitHub. #### What is not working as documented? Hardware transcoding can't transcoding iPhone 12 Pro's recording videos. ffmpeg encoder fallback to libh264 from h264_qsv Video metadata and trace log: ``` Metadata: compatible_brands: qt major_brand : qt minor_version : 0 com.apple.quicktime.location.accuracy.horizontal: 2000.000000 com.apple.quicktime.make: Apple com.apple.quicktime.model: iPhone 12 Pro com.apple.quicktime.software: 16.3 encoder : Lavf59.27.100 Duration: 00:01:06.76, start: 0.000000, bitrate: 9810 kb/s Stream #0:0[0x1](und): Video: hevc (Main 10) (hvc1 / 0x31637668), yuv420p10le(tv, bt2020nc/bt2020/arib-std-b67), 1920x1080 [SAR 1:1 DAR 16:9], 9627 kb/s, 30 fps, 30 tbr, 90k tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 178 kb/s (default) Metadata: handler_name : Stereo vendor_id : [0][0][0][0] Stream mapping: Stream #0:0 -> #0:0 (hevc (hevc_qsv) -> h264 (h264_qsv)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) [h264_qsv @ 0x5f6b7e068880] Current pixel format is unsupported [h264_qsv @ 0x5f6b7e068880] some encoding parameters are not supported by the QSV runtime. Please double check the input parameters. [vost#0:0/h264_qsv @ 0x5f6b7e0e3400] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height. Error while filtering: Function not implemented [hevc_qsv @ 0x5f6b7e13d7c0] A decode call did not consume any data: expect more data at input (-10) Last message repeated 2 times [out#0/mp4 @ 0x5f6b7e0811c0] 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= 0kB time=00:00:00.04 bitrate= 0.0kbits/s speed=1.01x [aac @ 0x5f6b7e0bfb80] Qavg: 18036.307 Conversion failed! ``` #### What could be the cause of your problem? FFmpeg intel_qsv encoder not support h264 10bit input, so https://github.com/photoprism/photoprism/blob/7346dd64d7c07d693131c9c50058bc746a79b91f/internal/ffmpeg/config.go#L21 the end of the `scale_qsv` parameter should add `:format=nv12`. I have tested it and it works. #### Which software versions do you use? Photoprism 240531 amd64 docker #### On what kind of device is PhotoPrism installed? Intel N100 with Alder Lake N Graphics
deekerman 2026-02-20 01:06:51 -05:00
Author
Owner

@lastzero commented on GitHub (Jul 6, 2024):

Could you please provide the complete command / parameter string that works for you? We can then change the code accordingly if you don't want to submit a pull request for it. Thank you very much!

@lastzero commented on GitHub (Jul 6, 2024): Could you please provide the complete command / parameter string that works for you? We can then change the code accordingly if you don't want to submit a pull request for it. Thank you very much!
Author
Owner

@hicasper commented on GitHub (Jul 6, 2024):

Sure, here is my command string in bash(contains escape charater \) :

/usr/bin/ffmpeg -hwaccel qsv -init_hw_device qsv=hw:/dev/dri/renderD128 \
  -filter_hw_device hw -hwaccel_output_format qsv \
  -i /photoprism/originals/source.mp4 \
  -c:a aac -vf "scale_qsv=w='if(gte(iw\,ih)\,min(1280\,iw)\,-1)':h='if(gte(iw\,ih)\,-1\,min(1280\,ih))':format=nv12" \
  -c:v h264_qsv -map 0:v:0 -map 0:a:0? -r 30 -b:v 10M \
  -f mp4 -movflags +faststart -y target.mp4.avc

The reason I don't submit the pr is because I don't know if I should add -init_hw_device qsv=hw:/dev/dri/renderD128 -filter_hw_device hw -hwaccel_output_format qsv, it seems like has been removed from the source code, but the log shows that it still exist.

@hicasper commented on GitHub (Jul 6, 2024): Sure, here is my command string in bash(contains escape charater `\`) : ``` /usr/bin/ffmpeg -hwaccel qsv -init_hw_device qsv=hw:/dev/dri/renderD128 \ -filter_hw_device hw -hwaccel_output_format qsv \ -i /photoprism/originals/source.mp4 \ -c:a aac -vf "scale_qsv=w='if(gte(iw\,ih)\,min(1280\,iw)\,-1)':h='if(gte(iw\,ih)\,-1\,min(1280\,ih))':format=nv12" \ -c:v h264_qsv -map 0:v:0 -map 0:a:0? -r 30 -b:v 10M \ -f mp4 -movflags +faststart -y target.mp4.avc ``` The reason I don't submit the pr is because I don't know if I should add `-init_hw_device qsv=hw:/dev/dri/renderD128 -filter_hw_device hw -hwaccel_output_format qsv`, it seems like has been removed from the source code, but the log shows that it still exist.
Author
Owner

@lastzero commented on GitHub (Jul 7, 2024):

Thank you very much! Our development preview build has been updated so you can test these changes:

@lastzero commented on GitHub (Jul 7, 2024): Thank you very much! Our development preview build has been updated so you can test these changes: - https://docs.photoprism.app/release-notes/#development-preview - https://docs.photoprism.app/getting-started/updates/#development-preview
Author
Owner

@hicasper commented on GitHub (Jul 8, 2024):

It works well with ffmpeg 6, but ffmpeg 7 seems still have some problem, fixed in #4382

@hicasper commented on GitHub (Jul 8, 2024): It works well with ffmpeg 6, but ffmpeg 7 seems still have some problem, fixed in #4382
Author
Owner

@lastzero commented on GitHub (Jul 8, 2024):

The static version of FFmpeg 7 does not support hardware transcoding:

@lastzero commented on GitHub (Jul 8, 2024): The static version of FFmpeg 7 does not support hardware transcoding: - https://docs.photoprism.app/getting-started/advanced/transcoding/#software-transcoding
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/photoprism#2133
No description provided.