jlesage / docker-handbrake

Docker container for HandBrake
MIT License
846 stars 97 forks source link

Docker Compose HW Acceleration #45

Open josjaf opened 5 years ago

josjaf commented 5 years ago

Hi, I'm trying to pass in the hw driver to the container on docker compose. is this via a device?

jlesage commented 5 years ago

Yes, you would need something like:

devices:
  - "/dev/dri:/dev/dri"

See https://docs.docker.com/compose/compose-file/#devices and https://github.com/jlesage/docker-handbrake#intel-quick-sync-video for more details.

backles commented 5 years ago

I am experiencing the same problem. I have exposed the device in the docker file. I am executing the container in high privledge and it sees 264 & 265 qsv and will decode but fails to encode either it just says encode failed. I have a synology DS 918+. va_getdrivename() fails with 1.

I may be barking up the wrong tree but i was able to pass in the environment var for the driver name & path but now it goes one step further and says it failed to va_opendriver() with -1

jlesage commented 5 years ago

Are you seeing the QSV encoders in the list?

backles commented 5 years ago

Yes I see it in the list and it does pass 1 fine but then on pass two immediately says “encode failed”. When I disable two pass and just do one pass I get the same result immediately saying “encode failed”. I am happy to provide information to help debug this.

Sent from my iPhone

On Apr 1, 2019, at 8:56 AM, Jocelyn Le Sage notifications@github.com wrote:

Are you seeing the QSV encoders in the list?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

jlesage commented 5 years ago

Are you using the latest docker image? You can also provide the full HandBrake log, located at ghb/Activity.log.XXX under the directory you mapped to /config.

backles commented 5 years ago

I am using the latest I’ve cleared and rebuilt the container twice yesterday after ensuring the latest was pulled. I will upload the log around 5:30PM PDT tonight.

Sent from my iPhone

On Apr 1, 2019, at 10:31 AM, Jocelyn Le Sage notifications@github.com wrote:

Are you using the latest docker image? You can also provide the full HandBrake log, located at ghb/Activity.log.XXX under the directory you mapped to /config.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

backles commented 5 years ago

Here is the Activity.log file Activity.log

jlesage commented 5 years ago

It seems that you don't have pulled the latest image. The log file indicate that your have HandBrake 1.1.2, while the latest image has version 1.2.2..

You can get the image version you have by running the following command:

docker inspect <container name> | grep org.label-schema.version
Numline1 commented 5 years ago

Hi, I'm experiencing similar issue. I'm attaching my log, along with my docker-compose:

  handbrake:
    image: jlesage/handbrake
    container_name: handbrake
    restart: always
    privileged: true
    devices:
      - "/dev/dri:/dev/dri"
    volumes:
      - "~/docker/handbrake:/config:rw"
      - "/mnt/alien-storage-1/smb_hybeshare:/storage:ro"
      - "/mnt/alien-storage-1/smb_hybeshare/hb-watch:/watch:rw"
      - "/mnt/alien-storage-1/smb_hybeshare/hb-output:/output:rw"
    labels:
      - "traefik.enable=true"
      - "traefik.backend=handbrake"
      - "traefik.port=5800"
      - "traefik.frontend.redirect.regex=^(.*)/handbrake$$"
      - "traefik.frontend.redirect.replacement=$$1/handbrake/"
      - "traefik.frontend.rule=PathPrefix: /handbrake; ReplacePathRegex: ^/handbrake/(.*) /$$1"
[00:07:16] hb_display_init: attempting VA driver 'iHD'
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_4
libva error: /opt/intel/mediasdk/lib64/iHD_drv_video.so init failed
libva info: va_openDriver() returns 1
[00:07:16] hb_display_init: attempting VA driver 'i965'
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'i965'
libva info: Trying to open /opt/intel/mediasdk/lib64/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_4
libva info: va_openDriver() returns 0
Cannot load libnvidia-encode.so.1
Cannot load libnvidia-encode.so.1
Cannot load libnvidia-encode.so.1
Cannot load libnvidia-encode.so.1
[00:07:16] hb_init: starting libhb thread
[00:07:16] hb_init: starting libhb thread
[00:07:16] hb_init: starting libhb thread
[00:07:34] CPU: Intel(R) Pentium(R) CPU G3220 @ 3.00GHz
[00:07:34]  - Intel microarchitecture Haswell
[00:07:34]  - logical processor count: 2
[00:07:34] Intel Quick Sync Video support: yes
[00:07:34]  - Intel Media SDK hardware: API 1.28 (minimum: 1.3)
[00:07:34]  - H.264 encoder: yes
[00:07:34]     - preferred implementation: hardware (any) via D3D11
[00:07:34]     - capabilities (hardware):  breftype la+i+downs vsinfo opt1 opt2+mbbrc+extbrc+trellis+ib_adapt+nmpslice
[00:07:34]  - H.265 encoder: no
[00:07:34] hb_scan: path=/storage/upload/complete/redacted.mkv, title_index=0
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:323: failed opening UDF image /storage/upload/complete/redacted.mkv
disc.c:424: error opening file BDMV/index.bdmv
disc.c:424: error opening file BDMV/BACKUP/index.bdmv
[00:07:34] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.0
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[00:07:34] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from '/storage/upload/complete/redacted.mkv':
  Metadata:
    encoder         : libebml v1.3.6 + libmatroska v1.4.9
    creation_time   : 2018-08-07T12:32:31.000000Z
  Duration: 00:44:16.91, start: 0.000000, bitrate: 4017 kb/s
    Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv), 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
    Metadata:
      BPS-eng         : 3375255
      DURATION-eng    : 00:44:16.905000000
      NUMBER_OF_FRAMES-eng: 63702
      NUMBER_OF_BYTES-eng: 1120966778
      _STATISTICS_WRITING_APP-eng: mkvmerge v25.0.0 ('Prog Noir') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-08-07 12:32:31
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: eac3, 48000 Hz, 6 channels, fltp (default)
    Metadata:
      BPS-eng         : 640000
      DURATION-eng    : 00:44:16.832000000
      NUMBER_OF_FRAMES-eng: 83026
      NUMBER_OF_BYTES-eng: 212546560
      _STATISTICS_WRITING_APP-eng: mkvmerge v25.0.0 ('Prog Noir') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-08-07 12:32:31
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 400x578, 90k tbr, 90k tbn, 90k tbc
    Metadata:
      filename        : cover.jpg
      mimetype        : image/jpeg
[00:07:34] scan: decoding previews for title 1
[00:07:34] scan: audio 0x1: eac3, rate=48000Hz, bitrate=640000 English (E-AC3) (5.1 ch)
[00:07:36] scan: 10 previews, 1920x1080, 23.976 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1
[00:07:36] scan: supported video decoders: avcodec qsv
[00:07:36] libhb: scan thread found 1 valid title(s)
[00:07:52] gtkgui: Modified Preset: /Matroska/H.264 MKV 2160p60
[00:07:52] 1 job(s) to process
[00:07:52] json job:
{
    "Audio": {
        "AudioList": [
            {
                "Bitrate": 160,
                "CompressionLevel": -1.0,
                "DRC": 0.0,
                "DitherMethod": "auto",
                "Encoder": "fdk_aac",
                "Gain": 0.0,
                "Mixdown": "stereo",
                "NormalizeMixLevel": false,
                "PresetEncoder": "fdk_aac",
                "Quality": -3.0,
                "Samplerate": 0,
                "Track": 0
            }
        ],
        "CopyMask": [
            "copy:aac"
        ],
        "FallbackEncoder": "fdk_aac"
    },
    "Destination": {
        "AlignAVStart": false,
        "ChapterList": [
            {
                "Name": ""
            }
        ],
        "ChapterMarkers": false,
        "File": "/output/redacted (2).mkv",
        "InlineParameterSets": false,
        "Mp4Options": {
            "IpodAtom": false,
            "Mp4Optimize": false
        },
        "Mux": "mkv"
    },
    "Filters": {
        "FilterList": [
            {
                "ID": 3,
                "Settings": {
                    "block-height": "16",
                    "block-thresh": "40",
                    "block-width": "16",
                    "filter-mode": "2",
                    "mode": "3",
                    "motion-thresh": "1",
                    "spatial-metric": "2",
                    "spatial-thresh": "1"
                }
            },
            {
                "ID": 4,
                "Settings": {
                    "mode": "7"
                }
            },
            {
                "ID": 6,
                "Settings": {
                    "mode": 2,
                    "rate": "27000000/450000"
                }
            },
            {
                "ID": 11,
                "Settings": {
                    "crop-bottom": 0,
                    "crop-left": 0,
                    "crop-right": 0,
                    "crop-top": 0,
                    "height": 1080,
                    "width": 1920
                }
            }
        ]
    },
    "Metadata": {
        "Name": "redacted"
    },
    "PAR": {
        "Den": 1,
        "Num": 1
    },
    "SequenceID": 0,
    "Source": {
        "Angle": 0,
        "Path": "/storage/upload/complete/redacted.mkv",
        "Range": {
            "End": 1,
            "Start": 1,
            "Type": "chapter"
        },
        "Title": 1
    },
    "Subtitle": {
        "Search": {
            "Burn": true,
            "Default": false,
            "Enable": false,
            "Forced": false
        },
        "SubtitleList": []
    },
    "Video": {
        "ColorMatrix": 1,
        "ColorPrimaries": 1,
        "ColorTransfer": 1,
        "Encoder": "qsv_h264",
        "Level": "auto",
        "Options": "",
        "Preset": "balanced",
        "Profile": "auto",
        "QSV": {
            "AsyncDepth": 4,
            "Decode": false
        },
        "Quality": 15.0,
        "Tune": "",
        "Turbo": false,
        "TwoPass": false
    }
}
[00:07:52] CPU: Intel(R) Pentium(R) CPU G3220 @ 3.00GHz
[00:07:52]  - Intel microarchitecture Haswell
[00:07:52]  - logical processor count: 2
[00:07:52] Intel Quick Sync Video support: yes
[00:07:52]  - Intel Media SDK hardware: API 1.28 (minimum: 1.3)
[00:07:52]  - H.264 encoder: yes
[00:07:52]     - preferred implementation: hardware (any) via D3D11
[00:07:52]     - capabilities (hardware):  breftype la+i+downs vsinfo opt1 opt2+mbbrc+extbrc+trellis+ib_adapt+nmpslice
[00:07:52]  - H.265 encoder: no
[00:07:52] hb_scan: path=/storage/upload/complete/redacted.mkv, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:323: failed opening UDF image /storage/upload/complete/redacted.mkv
disc.c:424: error opening file BDMV/index.bdmv
disc.c:424: error opening file BDMV/BACKUP/index.bdmv
[00:07:52] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.0
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[00:07:52] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from '/storage/upload/complete/redacted.mkv':
  Metadata:
    encoder         : libebml v1.3.6 + libmatroska v1.4.9
    creation_time   : 2018-08-07T12:32:31.000000Z
  Duration: 00:44:16.91, start: 0.000000, bitrate: 4017 kb/s
    Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv), 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
    Metadata:
      BPS-eng         : 3375255
      DURATION-eng    : 00:44:16.905000000
      NUMBER_OF_FRAMES-eng: 63702
      NUMBER_OF_BYTES-eng: 1120966778
      _STATISTICS_WRITING_APP-eng: mkvmerge v25.0.0 ('Prog Noir') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-08-07 12:32:31
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: eac3, 48000 Hz, 6 channels, fltp (default)
    Metadata:
      BPS-eng         : 640000
      DURATION-eng    : 00:44:16.832000000
      NUMBER_OF_FRAMES-eng: 83026
      NUMBER_OF_BYTES-eng: 212546560
      _STATISTICS_WRITING_APP-eng: mkvmerge v25.0.0 ('Prog Noir') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-08-07 12:32:31
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 400x578, 90k tbr, 90k tbn, 90k tbc
    Metadata:
      filename        : cover.jpg
      mimetype        : image/jpeg
[00:07:52] scan: decoding previews for title 1
[00:07:52] scan: audio 0x1: eac3, rate=48000Hz, bitrate=640000 English (E-AC3) (5.1 ch)
[00:07:54] scan: 10 previews, 1920x1080, 23.976 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1
[00:07:54] scan: supported video decoders: avcodec qsv
[00:07:54] libhb: scan thread found 1 valid title(s)
[00:07:54] starting job
[00:07:54] decomb filter thread started for segment 0
[00:07:54] job configuration:
[00:07:54]  * source
[00:07:54] mask filter thread started for segment 1
[00:07:54]    + /storage/upload/complete/redacted.mkv
[00:07:54]    + title 1, chapter(s) 1 to 1
[00:07:54]    + container: matroska,webm
[00:07:54] mask erode thread started for segment 0
[00:07:54]    + data rate: 4017 kbps
[00:07:54]  * destination
[00:07:54]    + /output/redacted (2).mkv
[00:07:54] mask erode thread started for segment 1
[00:07:54]    + container: Matroska (libavformat)
[00:07:54]  * video track
[00:07:54]    + decoder: hevc
[00:07:54] mask dilate thread started for segment 0
[00:07:54]    + filters
[00:07:54] mask dilate thread started for segment 1
[00:07:54] yadif thread started for segment 0
[00:07:54] yadif thread started for segment 1
[00:07:54] decomb check thread started for segment 1
[00:07:54]      + Comb Detect (mode=3:spatial-metric=2:motion-thresh=1:spatial-thresh=1:filter-mode=2:block-thresh=40:block-width=16:block-height=16)
[00:07:54]      + Decomb (mode=39)
[00:07:54]      + Framerate Shaper (mode=2:rate=27000000/450000)
[00:07:54]        + frame rate: 23.976 fps -> peak rate limited to 60.000 fps
[00:07:54]      + Crop and Scale (width=1920:height=1080:crop-top=0:crop-bottom=0:crop-left=0:crop-right=0)
[00:07:54]        + source: 1920 * 1080, crop (0/0/0/0): 1920 * 1080, scale: 1920 * 1080
[00:07:54]    + Output geometry
[00:07:54]      + storage dimensions: 1920 x 1080
[00:07:54]      + pixel aspect ratio: 1 : 1
[00:07:54]      + display dimensions: 1920 x 1080
[00:07:54]    + encoder: H.264 (Intel Media SDK)
[00:07:54]      + preset:  balanced
[00:07:54]      + profile: auto
[00:07:54]      + level:   auto
[00:07:54]      + quality: 15.00 (QP)
[00:07:54]      + color profile: 1-1-1
[00:07:54]  * audio track 1
[00:07:54]    + decoder: English (E-AC3) (5.1 ch) (track 1, id 0x1)
[00:07:54]      + bitrate: 640 kbps, samplerate: 48000 Hz
[00:07:54]    + mixdown: Stereo
[00:07:54]    + dither: triangular
[00:07:54]    + encoder: AAC (libfdk_aac)
[00:07:54]      + bitrate: 160 kbps, samplerate: 48000 Hz
[00:07:54] sync: expecting 63702 video frames
[00:07:54] mask filter thread started for segment 0
[00:07:54] decomb check thread started for segment 0
[00:07:54] hb_display_init: using VA driver 'i965'
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'i965'
libva info: Trying to open /opt/intel/mediasdk/lib64/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_4
libva info: va_openDriver() returns 0
[00:07:54] decomb filter thread started for segment 1
[00:07:54] encqsvInit: using encode-only path
[00:07:54] encqsvInit: H.264/AVC High profile @ level 4.0
[00:07:54] encqsvInit: TargetUsage 4 AsyncDepth 4
[00:07:54] encqsvInit: GopRefDist 4 GopPicSize 32 NumRefFrame 3
[00:07:54] encqsvInit: BFramesMax 3 BRefType pyramid
[00:07:54] encqsvInit: RateControlMethod CQP with QPI 15 QPP 17 QPB 19
[00:07:54] sync: first pts video is 0
[00:07:54] sync: Chapter 1 at frame 1 time 0
[00:07:54] sync: first pts audio 0x1 is 1440
[00:07:55] qsv_enc_init: using 'hardware (1) via VAAPI' implementation, API: 1.28
libva info: VAEncMiscParameterBufferQualityLevel.quality_level (4) out of range (max 2).
[00:07:55] encqsv: MFXVideoENCODE_EncodeFrameAsync failed (-17)
[00:07:55] work: average encoding speed for job is 0.000000 fps
[00:07:55] comb detect: heavy 0 | light 0 | uncombed 29 | total 29
[00:07:55] decomb: deinterlaced 0 | blended 0 | unfiltered 25 | total 25
[00:07:55] vfr: 21 frames output, 0 dropped and 0 duped for CFR/PFR
[00:07:55] vfr: lost time: 0 (0 frames)
[00:07:55] vfr: gained time: 0 (0 frames) (0 not accounted for)
[00:07:55] eac3-decoder done: 96 frames, 0 decoder errors
[00:07:55] hevc-decoder done: 57 frames, 0 decoder errors
[00:07:55] sync: got 30 frames, 63702 expected
[00:07:55] sync: framerate min 23.981 fps, max 23.981 fps, avg 23.976 fps
[00:07:55] mux: track 0, 0 frames, 0 bytes, 0.00 kbps, fifo 8
[00:07:55] mux: track 1, 58 frames, 25187 bytes, 161.04 kbps, fifo 64
[00:07:55] libhb: work result = 4

The video encoder (h.264 qsv) is in the list, encoding itself fails after few seconds. Any thoughts on how to fix this? Thanks!

jlesage commented 5 years ago

Under the Video tab, try to toggle the value of the "Preset" setting. When changing the encoder, there may be some settings that are not properly "reset" in a way that are compatible with the new selected encoder.

Numline1 commented 5 years ago

@jlesage Thanks, that worked!