stremio-docker icon indicating copy to clipboard operation
stremio-docker copied to clipboard

Transcoding not working on Sandybridge IGPU

Open ameeno opened this issue 8 months ago • 7 comments

I have this in docker, and my jellyfin instance can transcode fine with similar settings, but this one doesn't do hardware accelaration, so display is laggy even tho downloads are fast!!

stremio-svr:
      image: tsaridas/stremio-docker:latest
      # render group is 105 on docker host.
      group_add:
        - "44"
        - "105" 
      devices:
        - "/dev/dri/card1:/dev/dri/card1"
        - "/dev/dri/renderD128:/dev/dri/renderD128"
      environment:
        - MESA_LOADER_DRIVER_OVERRIDE=crocus
        - LIBVA_DRIVER_NAME=i965
        - NO_CORS=1
        - CASTING_DISABLED=1

same settings work on my jellyfin but not this 1.

please help, my igpu is intel hd2000

ameeno avatar Apr 16 '25 00:04 ameeno

try to see if adding any of the missing packages from here https://wiki.alpinelinux.org/wiki/Intel_Video helps

tsaridas avatar Apr 22 '25 17:04 tsaridas

Hiya, I tried to docker build my own container/image using this dockerfile:

FROM tsaridas/stremio-docker:latest

# Add Intel VAAPI driver for Sandy Bridge and similar
RUN apk add --no-cache libva-intel-driver mesa-dri-gallium mesa-va-gallium intel-media-driver linux-firmware-i915

# Force VAAPI to use legacy i965 driver
ENV LIBVA_DRIVER_NAME=i965

# Clear cache
RUN rm -rf /var/cache/apk/* && rm -rf /tmp/*

#VOLUME ["/root/.stremio-server"]

# Expose default ports
EXPOSE 8080 11470 12470

ENTRYPOINT []

CMD ["./stremio-web-service-run.sh"]

and still unable to get hardware working:

    at Socket.emit (node:events:517:28)
    at finish (node:internal/streams/writable:748:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
-> GET /hlsv2/11470-qsv-linux-video-hevc.mkv/destroy 
hls-converter 11470-qsv-linux-video-hevc.mkv has been requested to be destroyed
hls-converter 11470-qsv-linux-video-hevc.mkv destoyed
hls-converter - Tests failed for [video] hw accel profile: qsv-linux
hls-converter - Some tests failed for hw accel profile: qsv-linux
hls-converter - Testing video hw accel for profile: nvenc-linux
-> GET /hlsv2/11470-nvenc-linux-video-hevc.mkv/video0.m3u8?mediaURL=http%3A%2F%2F127.0.0.1%3A11470%2Fsamples%2Fhevc.mkv&profile=nvenc-linux&maxWidth=1200 
hls-converter 11470-qsv-linux-video-hevc.mkv will be destroyed due to passing concurrency of 1
-> GET /samples/hevc.mkv 
Error: stream ended
    at Socket.onFinished (/srv/stremio-server/server.js:76500:145)
    at Socket.<anonymous> (node:internal/util:530:12)
    at Socket.onfinish (node:internal/streams/end-of-stream:113:16)
    at Socket.emit (node:events:517:28)
    at finish (node:internal/streams/writable:748:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
-> GET /hlsv2/11470-nvenc-linux-video-hevc.mkv/destroy 
hls-converter 11470-nvenc-linux-video-hevc.mkv has been requested to be destroyed
hls-converter 11470-nvenc-linux-video-hevc.mkv destoyed
hls-converter - Tests failed for [video] hw accel profile: nvenc-linux
hls-converter - Some tests failed for hw accel profile: nvenc-linux
hls-converter - Testing video hw accel for profile: vaapi-renderD128
-> GET /hlsv2/11470-vaapi-renderD128-video-hevc.mkv/video0.m3u8?mediaURL=http%3A%2F%2F127.0.0.1%3A11470%2Fsamples%2Fhevc.mkv&profile=vaapi-renderD128&maxWidth=1200 
hls-converter 11470-nvenc-linux-video-hevc.mkv will be destroyed due to passing concurrency of 1
-> GET /samples/hevc.mkv 
-> GET /samples/hevc.mkv bytes=0-
Error: stream ended
    at Socket.onFinished (/srv/stremio-server/server.js:76500:145)
    at Socket.<anonymous> (node:internal/util:530:12)
    at Socket.onfinish (node:internal/streams/end-of-stream:113:16)
    at Socket.emit (node:events:517:28)
    at finish (node:internal/streams/writable:748:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
-> GET /hlsv2/11470-vaapi-renderD128-video-hevc.mkv/destroy 
hls-converter 11470-vaapi-renderD128-video-hevc.mkv has been requested to be destroyed
hls-converter 11470-vaapi-renderD128-video-hevc.mkv destoyed
hls-converter - Tests failed for [video] hw accel profile: vaapi-renderD128
hls-converter - Some tests failed for hw accel profile: vaapi-renderD128
hls-converter - Tests for hardware accelerated transcoding finished, no viable acceleration profiles detected
[2025-04-22T18:20:47.406Z]  "GET /service-worker.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0"
[2025-04-22T18:20:47.469Z]  "GET /workbox-1f84e78b.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0"
-> GET /network-info 
-> GET /casting 
-> GET /device-info 
hls-converter - Initiating tests for hardware accelerated transcoding support, possible options: qsv-linux,nvenc-linux,vaapi-renderD128
hls-converter - Testing video hw accel for profile: qsv-linux
-> GET /settings 
-> GET /hlsv2/11470-qsv-linux-video-hevc.mkv/video0.m3u8?mediaURL=http%3A%2F%2F127.0.0.1%3A11470%2Fsamples%2Fhevc.mkv&profile=qsv-linux&maxWidth=1200 
hls-converter 11470-vaapi-renderD128-video-hevc.mkv will be destroyed due to passing concurrency of 1
-> GET /samples/hevc.mkv 
Error: stream ended
    at Socket.onFinished (/srv/stremio-server/server.js:76500:145)
    at Socket.<anonymous> (node:internal/util:530:12)
    at Socket.onfinish (node:internal/streams/end-of-stream:113:16)
    at Socket.emit (node:events:517:28)
    at finish (node:internal/streams/writable:748:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
-> GET /hlsv2/11470-qsv-linux-video-hevc.mkv/destroy 
hls-converter 11470-qsv-linux-video-hevc.mkv has been requested to be destroyed
hls-converter 11470-qsv-linux-video-hevc.mkv destoyed
hls-converter - Tests failed for [video] hw accel profile: qsv-linux
hls-converter - Some tests failed for hw accel profile: qsv-linux
hls-converter - Testing video hw accel for profile: nvenc-linux
-> GET /hlsv2/11470-nvenc-linux-video-hevc.mkv/video0.m3u8?mediaURL=http%3A%2F%2F127.0.0.1%3A11470%2Fsamples%2Fhevc.mkv&profile=nvenc-linux&maxWidth=1200 
hls-converter 11470-qsv-linux-video-hevc.mkv will be destroyed due to passing concurrency of 1
-> GET /samples/hevc.mkv 
Error: stream ended
    at Socket.onFinished (/srv/stremio-server/server.js:76500:145)
    at Socket.<anonymous> (node:internal/util:530:12)
    at Socket.onfinish (node:internal/streams/end-of-stream:113:16)
    at Socket.emit (node:events:517:28)
    at finish (node:internal/streams/writable:748:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
-> GET /hlsv2/11470-nvenc-linux-video-hevc.mkv/destroy 
hls-converter 11470-nvenc-linux-video-hevc.mkv has been requested to be destroyed
hls-converter 11470-nvenc-linux-video-hevc.mkv destoyed
hls-converter - Tests failed for [video] hw accel profile: nvenc-linux
hls-converter - Some tests failed for hw accel profile: nvenc-linux
hls-converter - Testing video hw accel for profile: vaapi-renderD128
-> GET /hlsv2/11470-vaapi-renderD128-video-hevc.mkv/video0.m3u8?mediaURL=http%3A%2F%2F127.0.0.1%3A11470%2Fsamples%2Fhevc.mkv&profile=vaapi-renderD128&maxWidth=1200 
hls-converter 11470-nvenc-linux-video-hevc.mkv will be destroyed due to passing concurrency of 1
-> GET /samples/hevc.mkv 
-> GET /samples/hevc.mkv bytes=0-
Error: stream ended
    at Socket.onFinished (/srv/stremio-server/server.js:76500:145)
    at Socket.<anonymous> (node:internal/util:530:12)
    at Socket.onfinish (node:internal/streams/end-of-stream:113:16)
    at Socket.emit (node:events:517:28)
    at finish (node:internal/streams/writable:748:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
-> GET /hlsv2/11470-vaapi-renderD128-video-hevc.mkv/destroy 
hls-converter 11470-vaapi-renderD128-video-hevc.mkv has been requested to be destroyed
hls-converter 11470-vaapi-renderD128-video-hevc.mkv destoyed
hls-converter - Tests failed for [video] hw accel profile: vaapi-renderD128
hls-converter - Some tests failed for hw accel profile: vaapi-renderD128
hls-converter - Tests for hardware accelerated transcoding finished, no viable acceleration profiles detected
Resizing cache size to 2048MB from 0MB by deleting 0 files

ameeno avatar Apr 22 '25 18:04 ameeno

I wouldn't know how to troubleshoot this. did you get anywhere with it ?

tsaridas avatar Jun 01 '25 11:06 tsaridas

Hey @ameeno , so i have done quite some effort trying a bunch of things, TLDR; Our CPU does not support HEVC Profile 2 and will always fail the stremio transcoding test.

I am using an i5-4200u, to get hwaccl working on HOST and docker i needed these packages

intel-media-va-driver-non-free, i965-va-driver, vainfo and to expliclity pass these env variables :

LIBVA_DRIVER_NAME=i965
LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
LIBVA_DRIVER_DEVICE=/dev/dri/renderD128

As i also have a dedicated nvidia gpu which is default and breaks detection, i was able to get hwaccel running inside the docker image itself and confirmed it with intel_gpu_top on the host machine, however stremio hls seems to expect HEVC only

I think if we were to modify stremio hls to use H264 Profile only, we should be able to transcode h264 content just fine (and h265 falls back to CPU), i haven't gotten around to trying that, transcoding 1080p h265 on CPU is okayish here so its not a massive problem but i would like to get h264 gpu hwaccl working atleast.

And keep in mind to get the intel-media-va-driver-non-free that finally worked i had to switch to a debian env and re-write this repo's dockerfile extensively, its vibe coded so you might have some issues you need to debug and fix.

Fork : https://github.com/ananjaser1211/stremio-docker

Additional info :

vainfo from within the container -

error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.17.0
libva info: User environment variable requested driver 'i965'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_8
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.12.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Mobile - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD

H264 Transcoding test inside container

Image

intel_gpu_top on HOST

Image

H265/HEVC transcoding test inside container

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.10.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 25181 kb/s
  Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25175 kb/s, 30 fps, 30 tbr, 15360 tbn, 30 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
[hevc @ 0x557214448700] No support for codec hevc profile 1.
[hevc @ 0x557214448700] Failed setup for format vaapi_vld: hwaccel initialisation returned error.

ananjaser1211 avatar Jun 19 '25 19:06 ananjaser1211

Hey @ameeno , so i have done quite some effort trying a bunch of things, TLDR; Our CPU does not support HEVC Profile 2 and will always fail the stremio transcoding test.

I am using an i5-4200u, to get hwaccl working on HOST and docker i needed these packages

intel-media-va-driver-non-free, i965-va-driver, vainfo and to expliclity pass these env variables :

LIBVA_DRIVER_NAME=i965
LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
LIBVA_DRIVER_DEVICE=/dev/dri/renderD128

As i also have a dedicated nvidia gpu which is default and breaks detection, i was able to get hwaccel running inside the docker image itself and confirmed it with intel_gpu_top on the host machine, however stremio hls seems to expect HEVC only

I think if we were to modify stremio hls to use H264 Profile only, we should be able to transcode h264 content just fine (and h265 falls back to CPU), i haven't gotten around to trying that, transcoding 1080p h265 on CPU is okayish here so its not a massive problem but i would like to get h264 gpu hwaccl working atleast.

And keep in mind to get the intel-media-va-driver-non-free that finally worked i had to switch to a debian env and re-write this repo's dockerfile extensively, its vibe coded so you might have some issues you need to debug and fix.

Fork : https://github.com/ananjaser1211/stremio-docker

Additional info :

vainfo from within the container -

error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.17.0
libva info: User environment variable requested driver 'i965'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_8
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.12.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Mobile - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD

H264 Transcoding test inside container

Image

intel_gpu_top on HOST

Image

H265/HEVC transcoding test inside container

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.10.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 25181 kb/s
  Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25175 kb/s, 30 fps, 30 tbr, 15360 tbn, 30 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
[hevc @ 0x557214448700] No support for codec hevc profile 1.
[hevc @ 0x557214448700] Failed setup for format vaapi_vld: hwaccel initialisation returned error.

Thanks for sharing your detailed write-up, glad you made progress on this issue. I've experimented with my own Dockerfile to install the intel-va drivers, so I'll swap it out with yours and try with LIBVA_DRIVER_NAME=i965 in my compose file.

I'll give your work a shot and see if it improves things. Stremio is currently unusable for me due to frequent crashes after a few minutes, so any help is appreciated.

ameeno avatar Jun 19 '25 20:06 ameeno

@ameeno the ffmpeg build on this repo doesn't include --enable-hwaccel=hevc_vaapi . maybe thats the issue ? I'll try to add it and you can test.

@ananjaser1211 have you tried using nvidia with the alpine container ?

I'm thinking that maybe I also add a version of the node slim that has glibc to have better compatibility with nvidia and other cpus.

tsaridas avatar Jun 25 '25 19:06 tsaridas

@ameeno the ffmpeg build on this repo doesn't include --enable-hwaccel=hevc_vaapi . maybe thats the issue ? I'll try to add it and you can test.

@ananjaser1211 have you tried using nvidia with the alpine container ?

I'm thinking that maybe I also add a version of the node slim that has glibc to have better compatibility with nvidia and other cpus.

Hey mate, sorry for late response, i am unable to utilize the nvidia GPU in that machine sadly, nonetheless its quite an old one (GT740M) so i doubt it will work anyway

for older intel on the other hand i was unable to find intel-media-va-driver-non-free equivalent on alpine which was required to run hw accl on my chip (keeping in mind that it still lacked HEVC Profile 2 and wouldn't benefit stremio anyway)

i think adding hevc_vaapi should allow 6th gen intel and newer to work your image, granted they pass the /dev/dri device, i do have a machine with newer intel CPU once i get the opportunity ill give it a go and see how it goes.

ananjaser1211 avatar Jul 01 '25 05:07 ananjaser1211