FAQ  •  Register  •  Login

Synology DS214Play - Hardware transcoding test: help needed

<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Sun Jun 01, 2014 11:44 am

Synology DS214Play - Hardware transcoding test: help needed

After a frankly ridiculous amount of effort I think I have managed to build the heavily modified FFmpeg 2.0.2 from Synology's source code with hardware transcoding support via the Intel Streaming Media Driver for Evansport CPUs, with the additional stuff we need for Serviio (librtmp, libass, DTS support etc.). It has been so difficult because the dependency chain is vast, the modifications are hacky, and unfortunately many of the libraries are older versions that are very difficult to successfully compile. This difficulty is probably the reason it hasn't been implemented before, and also that the FFmpeg developers apparently have no interest in integrating support for something that's not really open source. The API and the headers are open source but the code remains proprietary, hidden away inside some binaries (libffmpeg_plugin.so, libismd_core.so, libismd_viddec.so, etc.). It's a shame, because QuickSync transcoding is in the same sorry state, even though it could be used to save a lot of power on any post-Sandy Bridge Intel CPU.

As well as providing full HD H.264 encoding in hardware this FFmpeg build should also manage simultaneous hardware decoding of VC-1, H.264, MPEG-4, MPEG-2 and AAC. It looks like the processor can also encode and decode most variants of AC3 and DTS but Synology have not hacked that into their sources.

However, since I don't own one of these products I need your help...

I will need an SSH connection to a DS214Play please to carry out some basic checks. On the Serviio side I believe no changes will be required. I will just use an ffmpeg wrapper to substitute commands (so '-c:v libx64' becomes '-c:v libh264smd' etc.). Send me a pm if you want to help!

And for the skeptics, here is my proof (it's running on a Ubuntu VM with all the libraries built locally, including the ones that are included with DSM). Note the message at the top about the platform_config driver - I guess that's how it activates the hardware:

  Code:
patters@ubuntu14:~/Downloads/i686/syno/ffmpeg-2.0.2-ismd$ ./ffmpeg
Error opening /proc/platform_config
Please ensure that:
        -The platform_config driver is properly loaded
ffmpeg version 2.0.2-SMD_enabled_with_DTS_remux_fix-compiled_by_patters_for_Serviio Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  1 2014 11:51:05 with gcc 4.6.3 (crosstool-NG 1.17.0)
  configuration: --arch=x86 --cpu=atom --enable-cross-compile --cross-prefix=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu- --target-os=linux --prefix=/usr/local/i686-pc-linux-gnu --enable-shared --disable-static --enable-pic --disable-ffplay --disable-ffserver --disable-debug --enable-pthreads --enable-libmp3lame --enable-librtmp --enable-libass --enable-libx264 --enable-libh264_smd --enable-smd --enable-gpl --enable-gnutls --pkg-config=pkg-config --extra-version=SMD_enabled_with_DTS_remux_fix-compiled_by_patters_for_Serviio
  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'


If it works, it will be phenomenal. ~15% CPU load on an Intel Atom CE while doing 1080p transcode from VC-1 to H.264 apparently:
http://www.anandtech.com/show/8020/syno ... ne-right/9
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Mon Jun 02, 2014 11:08 am

Re: Synology DS214Play - Hardware transcoding test: help nee

Ok, I have access to a DS214Play NAS. The binary runs and the rather huge dependency chain is ok. No platform_config driver error so it's looking good :)
  Code:
ffmpeg version 2.0.2-SMD_enabled_with_DTS_remux_fix-compiled_by_patters_for_Serviio Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  1 2014 11:51:05 with gcc 4.6.3 (crosstool-NG 1.17.0)
  configuration: --arch=x86 --cpu=atom --enable-cross-compile --cross-prefix=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu- --target-os=linux --prefix=/usr/local/i686-pc-linux-gnu --enable-shared --disable-static --enable-pic --disable-ffplay --disable-ffserver --disable-debug --enable-pthreads --enable-libmp3lame --enable-librtmp --enable-libass --enable-libx264 --enable-libh264_smd --enable-smd --enable-gpl --enable-gnutls --pkg-config=pkg-config --extra-version=SMD_enabled_with_DTS_remux_fix-compiled_by_patters_for_Serviio
  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'


  Code:
DS214Play> ldd ./ffmpeg
        linux-gate.so.1 =>  (0xffffe000)
        libavdevice.so.55 => /volume1/@tmp/ffmpeg/libavdevice.so.55 (0xb7797000)
        libavfilter.so.3 => /volume1/@tmp/ffmpeg/libavfilter.so.3 (0xb76b7000)
        libavformat.so.55 => /volume1/@tmp/ffmpeg/libavformat.so.55 (0xb7539000)
        libavcodec.so.55 => /volume1/@tmp/ffmpeg/libavcodec.so.55 (0xb67ba000)
        libpostproc.so.52 => /volume1/@tmp/ffmpeg/libpostproc.so.52 (0xb6789000)
        libswresample.so.0 => /volume1/@tmp/ffmpeg/libswresample.so.0 (0xb676f000)
        libswscale.so.2 => /volume1/@tmp/ffmpeg/libswscale.so.2 (0xb6704000)
        libavutil.so.52 => /volume1/@tmp/ffmpeg/libavutil.so.52 (0xb66c1000)
        libffmpeg_plugin.so => /lib/libffmpeg_plugin.so (0xb66ac000)
        libm.so.6 => /lib/libm.so.6 (0xb6681000)
        libjson-c.so.0 => /lib/libjson-c.so.0 (0xb6677000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb665c000)
        libc.so.6 => /lib/libc.so.6 (0xb64e4000)
        libismd_core.so => /lib/libismd_core.so (0xb64d6000)
        libismd_viddec.so => /lib/libismd_viddec.so (0xb64cd000)
        librt.so.1 => /lib/librt.so.1 (0xb64c3000)
        libass.so.5 => /volume1/@tmp/ffmpeg/libass.so.5 (0xb64a3000)
        librtmp.so.1 => /volume1/@tmp/ffmpeg/librtmp.so.1 (0xb6486000)
        libz.so.1 => /lib/libz.so.1 (0xb646f000)
        libgnutls.so.28 => /volume1/@tmp/ffmpeg/libgnutls.so.28 (0xb6359000)
        libx264.so.119 => /volume1/@tmp/ffmpeg/libx264.so.119 (0xb6214000)
        libmp3lame.so.0 => /lib/libmp3lame.so.0 (0xb61a0000)
        libdl.so.2 => /lib/libdl.so.2 (0xb619b000)
        libxml2.so.2 => /lib/libxml2.so.2 (0xb6044000)
        libismd_demux.so => /lib/libismd_demux.so (0xb6038000)
        libismd_vidrend.so => /lib/libismd_vidrend.so (0xb602e000)
        libismd_clock.so => /lib/libismd_clock.so (0xb602b000)
        libismd_audio.so => /lib/libismd_audio.so (0xb601b000)
        libismd_videnc.so => /lib/libismd_videnc.so (0xb6016000)
        libismd_vidpproc.so => /lib/libismd_vidpproc.so (0xb600f000)
        libismdmessage.so => /lib/libismdmessage.so (0xb600a000)
        libsven.so => /lib/libsven.so (0xb5ec9000)
        libpal.so => /lib/libpal.so (0xb5ec6000)
        libosal.so => /lib/libosal.so (0xb5ebd000)
        libplatform_config.so => /lib/libplatform_config.so (0xb5eb9000)
        libsystem_utils.so => /lib/libsystem_utils.so (0xb5eb6000)
        libismd_clock_recovery.so => /lib/libismd_clock_recovery.so (0xb5eb1000)
        /lib/ld-linux.so.2 (0xb77a4000)
        libfribidi.so.0 => /volume1/@tmp/ffmpeg/libfribidi.so.0 (0xb5e97000)
        libfontconfig.so.1 => /volume1/@tmp/ffmpeg/libfontconfig.so.1 (0xb5e54000)
        libfreetype.so.6 => /lib/libfreetype.so.6 (0xb5db0000)
        libhogweed.so.2 => /volume1/@tmp/ffmpeg/libhogweed.so.2 (0xb5d82000)
        libnettle.so.4 => /volume1/@tmp/ffmpeg/libnettle.so.4 (0xb5d4b000)
        libgmp.so.10 => /lib/libgmp.so.10 (0xb5ce3000)
        liblzma.so.5 => /lib/liblzma.so.5 (0xb5cbc000)
        libexpat.so.1 => /lib/libexpat.so.1 (0xb5c92000)
        libbz2.so.1.0 => /lib/libbz2.so.1.0 (0xb5c81000)
        libpng16.so.16 => /lib/libpng16.so.16 (0xb5c47000)


Time to try transcoding a VC-1 test file...
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Mon Jun 02, 2014 1:54 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

Hmmm. Something's not quite right. I had a lot of difficulty compiling the same x264 lib that Synology used (which their h264_smd encoder hooks into), and didn't think it would be important since I presumed it would be on the target system. However it isn't. Here's what I get so far:
  Code:
DS214Play> ./ffmpeg -i ~/hddvd_demo_1080p.mkv -prefer_smd -c:v h264_smd -vsync 2 -preset superfast -vprofile high -level 4.1 -x264opts ca
bac=0:bframes=0:keyint=75:min_keyint=75:scenecut=0:crf=25 -s 1920x1080 -b:v 4500k -c:a aac -b:a 128k -strict experimental -f mp4 ~/hddvd_demo_1
080p.mp4
ffmpeg version 2.0.2-SMD_enabled_with_DTS_remux_fix-compiled_by_patters_for_Serviio Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  1 2014 11:51:05 with gcc 4.6.3 (crosstool-NG 1.17.0)
  configuration: --arch=x86 --cpu=atom --enable-cross-compile --cross-prefix=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu- --target-os=linux --prefix=/usr/local/i686-pc-linux-gnu --enable-shared --disable-static --enable-pic --disable-ffplay --disable-ffserver --disable-debug --enable-pthreads --enable-libmp3lame --enable-librtmp --enable-libass --enable-libx264 --enable-libh264_smd --enable-smd --enable-gpl --enable-gnutls --pkg-config=pkg-config --extra-version=SMD_enabled_with_DTS_remux_fix-compiled_by_patters_for_Serviio
  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, matroska,webm, from '/var/services/homes/patters/hddvd_demo_1080p.mkv':
  Metadata:
    creation_time   : 2007-04-07 03:28:47
  Duration: 00:02:01.90, start: 0.000000, bitrate: 19153 kb/s
    Stream #0:0(eng): Video: vc1_smd (Advanced) (WVC1 / 0x31435657), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 tbr, 1k tbn, 59.94 tbc (default)
    Metadata:
      title           : 1080p VC-1
    Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 640 kb/s (default)
    Metadata:
      title           : Dolby Digital 2.0 640kbps
    Stream #0:2(eng): Audio: eac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
    Metadata:
      title           : Dolby Digital Plus 5.1 640kbps
SVENHeader @ sven_connect_to_shared_mem
Unable to mmap: Operation not permitted (1)
Unable to mmap: Operation not permitted (1)

*********Using Hardware H.264 Encoder **************
Output #0, mp4, to '/var/services/homes/patters/hddvd_demo_1080p.mp4':
    Stream #0:0(eng): Video: h264, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 4500 kb/s, 90k tbn, 29.97 tbc (default)
    Metadata:
      title           : 1080p VC-1
    Stream #0:1(eng): Audio: aac, 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      title           : Dolby Digital 2.0 640kbps
Stream mapping:
  Stream #0:0 -> #0:0 (vc1_smd -> h264_smd)
  Stream #0:1 -> #0:1 (ac3 -> aac)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

PeterHurn

Serviio newbie

Posts: 4

Joined: Mon Jun 02, 2014 3:27 pm

Location: Cambridge, United Kingdom

Post Mon Jun 02, 2014 3:30 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

Great work so far appreciate all the effort you are putting into this.

I have a DS214 Play if you require any other testers.

Kind regards,

Peter.
Samsung 55” ES8000 Series 8 SMART 3D Full HDLED TV
Synology 6TB 214Play NAS
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Mon Jun 02, 2014 5:30 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

Interesting. By extracting the ffmpeg binary from Videostation I observe the exact same error with that, so my compiled ffmpeg is possibly ok after all. I'm probably setting something wrong in my transcoding command. Unfortunately I'm not very familiar with libx264 in general so I'll need to investigate in more detail later tonight.
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Mon Jun 02, 2014 11:13 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

Aha, user space programs cannot write memory directly unless run as root:
http://stackoverflow.com/questions/2236 ... -permitted

Once I have root access I'll resume testing...
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Tue Jun 03, 2014 10:30 am

Re: Synology DS214Play - Hardware transcoding test: help nee

Awww yeah! We are in business:

  Code:
DS214Play> ./ffmpeg -i /var/services/homes/patters/hddvd_demo_1080p.mkv -threads 0 -prefer_smd -c:v h264_smd -vsync 2 -preset superfast -v
profile high -level 4.1 -x264opts cabac=0:bframes=0:keyint=75:min_keyint=75:scenecut=0:crf=25 -s 1920x1080 -b:v 4500k -c:a aac -b:a 128k -strict
 experimental -map 0:0 -map 0:1 -ac 2 -ss 0 -copyts /volume1/@tmp/hddvd_demo_1080p.mp4
ffmpeg version 2.0.2-SMD_enabled_with_DTS_remux_fix-compiled_by_patters_for_Serviio Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  1 2014 11:51:05 with gcc 4.6.3 (crosstool-NG 1.17.0)
  configuration: --arch=x86 --cpu=atom --enable-cross-compile --cross-prefix=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu- --target-os=linux --prefix=/usr/local/i686-pc-linux-gnu --enable-shared --disable-static --enable-pic --disable-ffplay --disable-ffserver --disable-debug --enable-pthreads --enable-libmp3lame --enable-librtmp --enable-libass --enable-libx264 --enable-libh264_smd --enable-smd --enable-gpl --enable-gnutls --pkg-config=pkg-config --extra-version=SMD_enabled_with_DTS_remux_fix-compiled_by_patters_for_Serviio
  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, matroska,webm, from '/var/services/homes/patters/hddvd_demo_1080p.mkv':
  Metadata:
    creation_time   : 2007-04-07 03:28:47
  Duration: 00:02:01.90, start: 0.000000, bitrate: 19153 kb/s
    Stream #0:0(eng): Video: vc1_smd (Advanced) (WVC1 / 0x31435657), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 tbr, 1k tbn, 59.94 tbc (default)
    Metadata:
      title           : 1080p VC-1
    Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 640 kb/s (default)
    Metadata:
      title           : Dolby Digital 2.0 640kbps
    Stream #0:2(eng): Audio: eac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
    Metadata:
      title           : Dolby Digital Plus 5.1 640kbps
File '/volume1/@tmp/hddvd_demo_1080p.mp4' already exists. Overwrite ? [y/N] y
[h264_smd @ 0x8095ec0] using SAR=1/1
[h264_smd @ 0x8095ec0] using cpu capabilities: none!
[h264_smd @ 0x8095ec0] profile High, level 4.1
[h264_smd @ 0x8095ec0] 264 - core 119 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x3:0x3 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=75 keyint_min=38 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=25.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00

*********Using Hardware H.264 Encoder **************
[vc1_smd @ 0x80902a0]
******************Using VC1 Hardware video decoder**************
Output #0, mp4, to '/volume1/@tmp/hddvd_demo_1080p.mp4':
  Metadata:
    encoder         : Lavf55.12.100
    Stream #0:0(eng): Video: h264 (h264_smd) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 4500 kb/s, 30k tbn, 29.97 tbc (default)
    Metadata:
      title           : 1080p VC-1
    Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      title           : Dolby Digital 2.0 640kbps
Stream mapping:
  Stream #0:0 -> #0:0 (vc1_smd -> h264_smd)
  Stream #0:1 -> #0:1 (ac3 -> aac)
****** Using SMD H/W VC1 Decoder and H/W H.264 Encoder(Pipelined Mode)*******
Press [q] to stop, [?] for help
frame= 2914 fps= 45 q=0.0 Lsize=   57453kB time=00:02:01.48 bitrate=3874.1kbits/s
video:55451kB audio:1898kB subtitle:0 global headers:0kB muxing overhead 0.180796%
[aac @ 0x80f47a0] 1 frames left in the queue on closing


There are some differences between my compiled binary and the Synology VideoStation one. Mine has a dependency to libx264.so.119. I couldn't get the whole thing to compile without that, because the h264_smd encoder apparently uses some of its function calls. But although Synology's binary was compiled with --enable-libx264 theirs is not linked to this external library. I also found libx264 version 119 exceptionally difficult to compile compared to the relative ease of 133 which the Serviio FFmpeg build uses. I had to disable thread support to get it to build - so I have some more work to do on it before it's ready.

Also notice that during my binary's encode it reports:
  Code:
[h264_smd @ 0x8095ec0] using cpu capabilities: none!


The Synology VideoStation binary reports:
  Code:
[h264_smd @ 0x8095360] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle Cache64
[h264_smd @ 0x8095360] profile High, level 4.1
[h264_smd @ 0x8095360] 264 - core 119 r0+4 470792a - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x3:0x3 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=75 keyint_min=38 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=25.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00


Performance doesn't seem to be impaired though. They each convert that 1920x1080 clip at 45fps with around 40% CPU. Given that a lot of that info is coming from 264 core 119 (i.e. libx264) then I guess this difference could be explained by my difficulties building it. Unfortunately using build 133 doesn't seem to allow the h264_smd encoder to work. I guess Synology's integration of the SMD support is very version-specific.

Here is the CPU performance during a full HD transcode:
  Code:
Mem: 604960K used, 111356K free, 0K shrd, 18328K buff, 368756K cached
CPU: 13.8% usr 33.1% sys  0.0% nic 52.5% idle  0.2% io  0.0% irq  0.1% sirq
Load average: 6.92 6.30 6.04 4/359 9695
  PID  PPID USER     STAT   VSZ %MEM %CPU COMMAND
13475     2 root     RW       0  0.0 24.8 [VidEnc_Input]
 9622  9496 root     S     124m 17.7 17.2 ./ffmpeg -i /var/services/homes/patters/hddvd_demo_1080p.mkv -threads 0 -prefer_smd -c:v h264_smd
13022     2 root     SW       0  0.0  0.4 [Clock_ISR]
13679     2 root     SW       0  0.0  0.3 [VidPProc_IO]
13442     2 root     SW       0  0.0  0.2 [VidDec_hal_Wkld]
13395     2 root     SW       0  0.0  0.1 [Demux_IO]
 7071     1 root     S    26444  3.6  0.1 scemd
15398     1 root     S <  20724  2.8  0.1 /var/packages/AudioStation/target/sbin/synoaudiod
 9692  9688 root     R     3864  0.5  0.1 top
13499     2 root     SW       0  0.0  0.1 [Audio_Timing]
  533     2 root     SW<      0  0.0  0.1 [kswapd0]
13437     2 root     SW       0  0.0  0.1 [VidDec_Output]
13436     2 root     SW       0  0.0  0.1 [VidDec_Input]
15644 15638 serviio  S     661m 93.9  0.0 /var/packages/JavaManager/target/Java/jre/bin/java -Xmx512m -Xms20M -XX:+UseParNewGC -XX:MinHeapF
16145     1 root     S     186m 26.4  0.0 php-fpm: master process (/etc/php/php-fpm.conf)
15735     1 root     S    86120 11.9  0.0 /var/packages/CloudStation/target/sbin/syncd -c /volume1/@cloudstation/@sync -p 6690 -u /volume1/
 9482  5215 root     S    20688  2.8  0.0 sshd: root@pts/2
11834     1 root     S <  17460  2.4  0.0 /usr/bin/httpd -DSSL -DSPDY -f /etc/httpd/conf/httpd.conf-sys
10848     1 root     S    15160  2.1  0.0 /usr/syno/sbin/snmpd -Ln -c /usr/syno/etc/snmpd.conf -p /var/run/snmpd.pid udp:161,udp6:161,tcp:1
15429     1 root     S <   9836  1.3  0.0 /var/packages/AudioStation/target/sbin/synorcd
13051     2 root     DW       0  0.0  0.0 [DisplayVBI]
13463     2 root     DW       0  0.0  0.0 [Mux_isr]
13476     2 root     SW       0  0.0  0.0 [VidEnc_Output]
13169     2 root     SW       0  0.0  0.0 [parse_encode_is]
13443     2 root     SW       0  0.0  0.0 [VidDec_hal_Pars]
13480     2 root     SW       0  0.0  0.0 [VidEnc_hal_isr]
13365     2 root     SW       0  0.0  0.0 [decode_mux_isr]
16339 16173 http     S     305m 43.5  0.0 /usr/bin/httpd -DSSL -DSPDY -DHAVE_PHP
16160 16145 http     S     187m 26.6  0.0 php-fpm: pool www
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Mon Jun 09, 2014 12:30 am

Re: Synology DS214Play - Hardware transcoding test: help nee

Fixed up that CPU features issue by recompiling libx264. I have confirmed that I can compile everything consistently now, which is a relief as I had been seeing to really odd behaviour. Everything looks good now for inclusion into the Synology build of Serviio. I just need details from Zip of all the encoding parameters that I'll need to substitute using a wrapper script for ffmpeg. I'll also need to amend profiles.xml to use H.264 as the preferred transcode format (instead of mpeg2video). I'll also need to change the Serviio package to run as root since this ffmpeg binary needs direct access to memory.

This example of an HD H.264 to smaller resolution H.264 transcode ran at 134 FPS with only 5% CPU use:
  Code:
DS214Play> ./ffmpeg -i /volume1/homes/patters/prometheus-tlrg_h1080p.mov -prefer_smd -copyts -c:v h264_smd -vsync 2 -preset superfast -vprofile main -level 4.0 -x264opts cabac=0:bframes=0:keyint=75:min_keyint=75:scenecut=0:crf=25 -vf scale=800:-1 -b:v 1500k -c:a copy -f mp4 /volume1/homes/patters/prometheus_480p_main_40.mp4
ffmpeg version 2.0.2-SMD_enabled_with_DTS_remux_fix-compiled_by_patters_for_Serviio Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  9 2014 00:54:38 with gcc 4.6.3 (crosstool-NG 1.17.0)
  configuration: --arch=x86 --cpu=atom --enable-cross-compile --cross-prefix=/usr/local/evansport-pc-linux-gnu/bin/i686-pc-linux-gnu- --target-os=linux --prefix=/usr/local/evansport-pc-linux-gnu --enable-shared --disable-static --enable-pic --disable-ffplay --disable-ffserver --disable-debug --enable-pthreads --enable-libmp3lame --enable-librtmp --enable-libass --enable-libx264 --enable-libh264_smd --enable-smd --enable-gpl --enable-gnutls --pkg-config=pkg-config --extra-version=SMD_enabled_with_DTS_remux_fix-compiled_by_patters_for_Serviio
  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/volume1/homes/patters/prometheus-tlrg_h1080p.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    creation_time   : 2012-03-16 23:15:31
    comment         : Encoded and delivered by apple.com/trailers/
    copyright       : © 2012 20th Century Fox. All Rights Reserved
    title           : Prometheus
    timecode        : 01:00:01:08
  Duration: 00:02:30.82, start: 0.000000, bitrate: 9716 kb/s
    Stream #0:0(eng): Video: h264_smd (Main) (avc1 / 0x31637661), yuv420p, 1920x816, 9614 kb/s, 23.98 fps, 23.98 tbr, 2997 tbn, 5994 tbc
    Metadata:
      creation_time   : 2012-03-16 23:15:31
      handler_name    : Apple Alias Data Handler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s
    Metadata:
      creation_time   : 2012-03-16 23:15:31
      handler_name    : Apple Alias Data Handler
    Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
    Metadata:
      creation_time   : 2012-03-16 23:15:31
      handler_name    : Apple Alias Data Handler
      timecode        : 01:00:01:08
[h264_smd @ 0x80a2780] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle Cache64
[h264_smd @ 0x80a2780] profile Main, level 4.0
[h264_smd @ 0x80a2780] 264 - core 119 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0x1 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=75 keyint_min=38 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=25.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00

*********Using Hardware H.264 Encoder **************
[h264_smd @ 0x808fa40]
******************Using H.264 Hardware video decoder**************
Output #0, mp4, to '/volume1/homes/patters/prometheus_480p_main_40.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    timecode        : 01:00:01:08
    comment         : Encoded and delivered by apple.com/trailers/
    copyright       : © 2012 20th Century Fox. All Rights Reserved
    title           : Prometheus
    encoder         : Lavf55.12.100
    Stream #0:0(eng): Video: h264 (h264_smd) ([33][0][0][0] / 0x0021), yuv420p, 800x340, q=-1--1, 1500 kb/s, 11988 tbn, 23.98 tbc
    Metadata:
      creation_time   : 2012-03-16 23:15:31
      handler_name    : Apple Alias Data Handler
    Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 96 kb/s
    Metadata:
      creation_time   : 2012-03-16 23:15:31
      handler_name    : Apple Alias Data Handler
Stream mapping:
  Stream #0:0 -> #0:0 (h264_smd -> h264_smd)
  Stream #0:1 -> #0:1 (copy)
****** Using SMD H/W H.264 Decoder and H/W H.264 Encoder(Pipelined Mode)*******
Press [q] to stop, [?] for help
frame= 3617 fps=134 q=0.0 Lsize=   23129kB time=00:02:30.85 bitrate=1256.0kbits/s
video:21259kB audio:1780kB subtitle:0 global headers:0kB muxing overhead 0.392911%
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Mon Jun 09, 2014 2:37 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

Got it compiled linked against the latest libx264 (core 142) :)
  Code:
[h264_smd @ 0x80a2780] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[h264_smd @ 0x80a2780] profile Main, level 4.0
[h264_smd @ 0x80a2780] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0x1 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=75 keyint_min=38 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=25.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00

*********Using Hardware H.264 Encoder **************
[h264_smd @ 0x808fa40]
******************Using H.264 Hardware video decoder**************
Output #0, mp4, to '/volume1/homes/patters/prometheus_480p.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    timecode        : 01:00:01:08
    comment         : Encoded and delivered by apple.com/trailers/
    copyright       : © 2012 20th Century Fox. All Rights Reserved
    title           : Prometheus
    encoder         : Lavf55.12.100
    Stream #0:0(eng): Video: h264 (h264_smd) ([33][0][0][0] / 0x0021), yuv420p, 800x340, q=-1--1, 1500 kb/s, 11988 tbn, 23.98 tbc
    Metadata:
      creation_time   : 2012-03-16 23:15:31
      handler_name    : Apple Alias Data Handler
    Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 96 kb/s
    Metadata:
      creation_time   : 2012-03-16 23:15:31
      handler_name    : Apple Alias Data Handler
Stream mapping:
  Stream #0:0 -> #0:0 (h264_smd -> h264_smd)
  Stream #0:1 -> #0:1 (copy)
****** Using SMD H/W H.264 Decoder and H/W H.264 Encoder(Pipelined Mode)*******
Press [q] to stop, [?] for help
frame= 3617 fps=133 q=0.0 Lsize=   23129kB time=00:02:30.85 bitrate=1256.0kbits/s
video:21259kB audio:1780kB subtitle:0 global headers:0kB muxing overhead 0.392911%
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

Mikesch

Serviio newbie

Posts: 2

Joined: Wed Jun 18, 2014 3:47 pm

Post Wed Jun 18, 2014 3:50 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

Wow, that's huge! :D I bought the DS214Play specifically for its streaming capabilities and was devastated to learn there is no DTS support from Synology. Can you give an estimate when your work will be included in the package?
<<

xgbi

Serviio newbie

Posts: 1

Joined: Fri Jun 20, 2014 8:14 am

Post Fri Jun 20, 2014 8:39 am

Re: Synology DS214Play - Hardware transcoding test: help nee

Hey there,

Just registered to tell you that you've done an awesome job.
I was wondering if you have a bit of information as to how you compile this FFMPEG version with the smd extensions?
I'm looking at implementing an H264_smd filter for Linphone (www.linphone.org) on my DS214, so that I can use it as a SIP server for transcoding and/or surveillance with my webcam. We already have an FFMPEG encoder/decoder interface, but I'd like to see if I can leverage on the hardware encoder in there.

Do you plan to disclose your compilation method?
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Tue Jun 24, 2014 9:25 am

Re: Synology DS214Play - Hardware transcoding test: help nee

Progress update - I have converted the package to run as root and written a more proper Linux daemon wrapper script that should cure that occasional problem where there is a running Serviio process that won't shut down. It seemed to happen to my NAS if I left it running for many weeks. I have also finished editing the whole of profiles.xml to maximize the use of H.264 instead of mpeg2video for transcoding.

The ffmpeg wrapper script is complete, but I have to do some testing to work out how to get a better look at the H.264 encoding settings. I have also updated the Java package for Synology to be self-healing when DSM updates remove environment variables from /etc/profile.

In real life I've got construction problems with my house that I'm getting fixed under warranty which is using up a lot of my time, however working on Serviio keeps my mind on something interesting at least!

And yes I will publish my compilation steps once I've released this new Serviio build. It's way too hard to do this stuff, so the more information that's 'out there' the better for everyone.
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

wijmaar

Serviio newbie

Posts: 1

Joined: Wed Jun 25, 2014 7:50 am

Post Wed Jun 25, 2014 7:52 am

Re: Synology DS214Play - Hardware transcoding test: help nee

Hey man! That is some awesome news! I was the first to start asking Plex about this, which resulted in a 400+ replies topic. Great that you have done it! :D :D If you need anymore testing options, please let me know! And good luck on the house :)

Regards
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Sat Jun 28, 2014 8:14 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

Only one hardware transcoding job can run at a time which could cause problems when using more than one renderer device:
  Code:
[h264_smd @ 0x80a6200] 264 - core 119 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=abr mbtree=1 bitrate=1500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Hardware transcoding is busy!!
[h264_smd @ 0x80a6200] Syno check hardware transcode falied
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Sun Jun 29, 2014 1:28 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

Now that I have carried out some more testing it unfortunately seems that libass does not behave properly for this SMD version of ffmpeg so it cannot burn in subtitles. I guess it will be related to the way that the video frames are sent to the encoder. Since I'm not a developer it's beyond my skills to resolve. I guess the SMD implementation in ffmpeg may be a little too hacky so it has broken some core ffmpeg functionality, but perhaps it's because libass itself would also need adapting for hardware encoding. I thought it might only apply to pipelined mode (when the HW decoder is also used) so I disabled that but the problem persists. The CPU stays at around 25% (one thread?) and the output file stays at zero bytes. FFmpeg doesn't crash, but it doesn't show encoding progress like it normally would. Here is my command line:
  Code:
./ffmpeg -prefer_smd -i Inside-Job-Trailer.mov -copyts -c:v h264_smd -vsync 2 -preset veryfast -vprofile high -level 4.1 -vf subtitles=filename='test.srt':charenc=UTF-8 -c:a copy -f mp4 inside_job_sub.mp4


I have asked the Synology developers if it might be some small detail that needs changing.
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Wed Jul 02, 2014 8:03 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

I hadn't realised that libass had moved from Google Code to Github where there is a newer version. This now has optimized assembler for the renderer on x86. It was worth rebuilding ffmpeg today in case this fixed the issue but unfortunately it didn't.
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

butch666

Serviio newbie

Posts: 1

Joined: Fri Jul 04, 2014 9:01 am

Post Fri Jul 04, 2014 9:07 am

Re: Synology DS214Play - Hardware transcoding test: help nee

Hi patters,

Sorry for spamming your very informative thread, but just wanted to give you a huge thumbs up for your efforts on getting this to work. With that level of commitment I do not doubt for a second that you will eventually find a solution to the remaining problems.

Wish you the best of luck and keep up the excellent work ;)
<<

Urbanshenkie

Serviio newbie

Posts: 2

Joined: Mon Jul 28, 2014 3:17 pm

Post Mon Jul 28, 2014 3:18 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

Any news yet ?

Verstuurd vanaf mijn Nexus 5 met Tapatalk
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Mon Jul 28, 2014 6:29 pm

Re: Synology DS214Play - Hardware transcoding test: help nee

I just heard back from the Synology development team (via support) and they have confirmed that the issues with burning hard subtitles into the video are somewhat expected. Subtitle rendering will not work while both hardware decoding and hardware encoding are in use (Pipelined mode). I guess this limitation could be inherent in the Intel chip design, since the stream data resides in the media codec's buffers at this point. Their suggested workaround is to use software decoding, allowing each frame to be composited using libass data, and then fed into the hardware encoder.

The odd thing is that I was certain I had tested this, but I tried again just now and it does indeed work. Perhaps I had some other fontconfig issues, or maybe I had tested using the older libass. Anyhow unfortunately the speed penalty of doing the decode in software means that it cannot keep up with realtime encoding, despite the hardware encoder :-( I could only get 20fps out of it on a 1080p file.

So we can get Serviio transcoding in hardware working, but the caveat will be that it cannot quite realtime transcode with hard subs. You'd need to start the movie, pause it and come back to watch it a bit later. It's a shame really because being able to do that would probably have tempted me to buy one. The remaining issue to resolve before releasing my dedicated Evansport build of Serviio is that I need to do some proper DLNA transcoding testing with it with an actual renderer device. Though I was able to test the basic functionality of ffmpeg remotely thanks to a kind volunteer in Poland, he reported that it wasn't transcoding properly for his PS3 and it was impractical to test any further. I have made a request to Synology for a review unit so we'll have to wait and see...
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Wed Jul 30, 2014 12:20 am

Re: Synology DS214Play - Hardware transcoding test: help nee

Well it's a no from Synology for the loan of a test unit. I've pm'ed a couple of the responders to this thread to see if they can test.
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
Next

Return to NAS installation

Who is online

Users browsing this forum: No registered users and 18 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.