Jump to content

H/W Transcode stuttering - i7-7500U / ubuntu 17.04


pgalbavy
 Share

Recommended Posts

pgalbavy

I found a number of other threads with similar symptoms but not quite the same hardware; The closest being https://emby.media/community/index.php?/topic/45550-transcoding-performance-vs-that-other-server/

 

I have a no-name i7 mini PC ("Intel® Core i7-7500U CPU @ 2.70GHz") running Ubuntu 17.04

 

Recently installed Emby (release) next to Plex and paid for Premiere because it seems like a right thing to do.

 

Anyway trying hardware transcode with the default ffpmeg fails:

[AVHWDeviceContext @ 0x50d4520] No VA display found for device: /dev/dri/renderD128.
[vaapi @ 0x312f1e0] Failed to create a VAAPI device

But using the system shipped one (/usr/bin/ffmpeg) works OK, in ubuntu 17.04 is claims:

ffmpeg version 3.2.4-1build2 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (Ubuntu 6.3.0-8ubuntu1) 20170221

Hardware transcoding works, CPU usage is reasonable (70-80% of one core) but playback stutters - play 10 seconds, stop 5, play 10 seconds, stop etc.

 

Not sure what this means (yet), but the only noticeable errors in the log are:

[h264 @ 0xc6763beea0] Hardware accelerated decoding with frame threading is known to be unstable and its use is discouraged.
Input stream #0:0 frame changed from size:1920x1080 fmt:yuv420p to size:1920x1080 fmt:vaapi_vld
Unrepairable overflow!

I've changed the CRF to 19 (from 23) with no difference, I've set the temporary path to a local scratch SSD with lots of space, turned off throttling. No effect. I have yet to try one of the custom ffmpeg builds, but looking at the log it's not the conversion performance that's the problem:

frame=10024 fps= 67 q=-0.0 size=N/A time=00:06:58.34 bitrate=N/A speed=2.81x
frame=10047 fps= 67 q=-0.0 size=N/A time=00:06:59.30 bitrate=N/A speed= 2.8x
frame=10073 fps= 67 q=-0.0 size=N/A time=00:07:00.39 bitrate=N/A speed= 2.8x

On the other hand, looking a bit more manually I *think* the stop/start is every time the m3u8 file is updated but "tail -f" doesn't work on that file for some reason, so it's hard to visually sync the changes to the display - just lots of repeated "ls -l"

 

I also tried the beta but with the .net install it seemed to not quite work so I hurriedly backed out deciding that a pre-release of a new system is not quite the right thing to do just now.

 

 

Any immediate suggestions and/or which logs would be useful?

 

Peter

Link to comment
Share on other sites

Guest plexman

I think if I'm not mistaken that the default ffmpeg that comes with emby doesn't have h264_vaapi enabled, so efectively with your system shipped it works. Do you mind posting your "vainfo" output?

Link to comment
Share on other sites

pgalbavy

Here you are:

error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.3)
vainfo: Driver version: Intel i965 driver for Intel(R) Kabylake - 1.7.3
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
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointEncSlice
      VAProfileVP9Profile2            : VAEntrypointVLD
Link to comment
Share on other sites

Guest plexman

The only thing that comes to my mind is that the "problem" might be your file. Because I can see that VAAPI works good, and the slutter in your playback could be because of the file, I don't really know.

 

EDIT: Are you specifying any threads? If so, try leaving in "auto" mode. https://emby.media/community/index.php?/topic/47388-transcoding-fails-decoding-with-frame-threading/?p=447314

Edited by plexman
Link to comment
Share on other sites

pgalbavy

Thanks, I tried both VC-1 and H.264 files (1080p) - both the same. With H/W transcode off *or* H/W transcode on Plex it works fine. Thread mode tried Auto / Max / 1 - all same.

 

Without knowing much - but enough to be dangerous - I am going to look more into how/why the file is split into small chunks and the update of the .m3u8 playlist file. I *suspect* that the remote player is being somehow triggered to reload the playlist file on each update and because it's remote (home->work) this takes a finite amount of time and may delay things. Why just me, I don't know.

Link to comment
Share on other sites

pgalbavy

Looking at the segment files produced there is a huge difference in sizes leading me to believe that either the stock Ubuntu ffmpeg or VA-API are doing the wrong thing. Off to locate a custom ffmpeg to test.

 

Details, same film, ignore first few segment as the difference is also large but the video is mostly blank screen intro:

 

s/w transcode:

2017-10-20 11:54:43.498 Info App: /usr/bin/ffmpeg -i file:"/media/hdd0/Films/8 Mile (2002) (BluRay).mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 libx264 -pix_fmt yuv420p -preset veryfast -crf 23 -maxrate 3616000 -bufsize 7232000 -profile:v high -level 4.1 -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -force_key_frames "expr:if(isnan(prev_forced_t),eq(t,t),gte(t,prev_forced_t+3))" -vf "scale=trunc(min(max(iw\,ih*dar)\,1280)/2)*2:trunc(ow/dar/2)*2" -copyts -vsync -1 -codec:a:0 aac -strict experimental -ac 6 -ab 384000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/media/ssd2/emby/transcoding-temp/972b38adc6bee77d80a4b01354556e5e.m3u8" -y "/media/ssd2/emby/transcoding-temp/972b38adc6bee77d80a4b01354556e5e%d.ts"

segment files:

-rwxrwxrwx 1 peter peter  652736 11:54:50 972b38adc6bee77d80a4b01354556e5e5.ts
-rwxrwxrwx 1 peter peter  309448 11:54:51 972b38adc6bee77d80a4b01354556e5e6.ts
-rwxrwxrwx 1 peter peter  264516 11:54:52 972b38adc6bee77d80a4b01354556e5e7.ts
-rwxrwxrwx 1 peter peter  181984 11:54:53 972b38adc6bee77d80a4b01354556e5e8.ts
-rwxrwxrwx 1 peter peter  188752 11:54:54 972b38adc6bee77d80a4b01354556e5e9.ts

 

 

h/w transcode:

2017-10-20 11:55:19.482 Info App: /usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i file:"/media/hdd0/Films/8 Mile (2002) (BluRay).mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi  -b:v 3616000 -maxrate 3616000 -bufsize 7232000 -level 41 -force_key_frames "expr:if(isnan(prev_forced_t),eq(t,t),gte(t,prev_forced_t+3))" -vf "format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=720" -copyts -vsync -1 -codec:a:0 aac -strict experimental -ac 6 -ab 384000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/media/ssd2/emby/transcoding-temp/3af734c95b2129a77a64da8f37c5c6a4.m3u8" -y "/media/ssd2/emby/transcoding-temp/3af734c95b2129a77a64da8f37c5c6a4%d.ts"

segment files:

-rwxrwxrwx 1 peter peter  464360 11:55:26 3af734c95b2129a77a64da8f37c5c6a45.ts
-rwxrwxrwx 1 peter peter 2040364 11:55:27 3af734c95b2129a77a64da8f37c5c6a46.ts
-rwxrwxrwx 1 peter peter 2327440 11:55:28 3af734c95b2129a77a64da8f37c5c6a47.ts
-rwxrwxrwx 1 peter peter  890932 11:55:29 3af734c95b2129a77a64da8f37c5c6a48.ts
-rwxrwxrwx 1 peter peter  447628 11:55:31 3af734c95b2129a77a64da8f37c5c6a49.ts
 
Link to comment
Share on other sites

pgalbavy

Well, I did a risky thing an updated to the 17.10 release remotely. After fixing my filesystem mount issue when I got home, I tested again. Same film, segments with h/w transcode:

-rwxrwxrwx 1 peter peter 1468656 Oct 20 18:54 28ba43c6a929e8fd98a0d06e7d042be45.ts
-rwxrwxrwx 1 peter peter 1094536 Oct 20 18:54 28ba43c6a929e8fd98a0d06e7d042be46.ts
-rwxrwxrwx 1 peter peter 1008808 Oct 20 18:54 28ba43c6a929e8fd98a0d06e7d042be47.ts
-rwxrwxrwx 1 peter peter  172020 Oct 20 18:54 28ba43c6a929e8fd98a0d06e7d042be48.ts
-rwxrwxrwx 1 peter peter  234060 Oct 20 18:54 28ba43c6a929e8fd98a0d06e7d042be49.ts

Significantly smaller. I am now however not at the end of a remote connection so can't confirm any change in actual streaming behaviour, but apart from segment 5 (the first) all the others are noticeably smaller in size.

 

The stock ffmpeg is now saying:

ffmpeg version 3.3.4-2 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.2.0-8ubuntu2)
  configuration: --prefix=/usr --extra-version=2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100

and vainfo shows updated i965 drivers:

sudo vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 0.40.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_40
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.40 (libva )
vainfo: Driver version: Intel i965 driver for Intel(R) Kabylake - 1.8.3
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointEncSlice
      VAProfileVP9Profile2            : VAEntrypointVLD

This is well on the way to solving my issue, hope this may help the next person to see this. Will confirm in a follow-up if remote playback is also really fixed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...