User:Mjb/Serviio

From Offset
< User:Mjb
Revision as of 19:15, 30 May 2018 by Mjb (talk | contribs) (Transcoding)
Jump to navigationJump to search

Serviio is a streaming media server. I use it to allow DLNA-capable devices to access video, audio and image files on my computer. For example, I can use my TV, through my Blu-Ray Disc (BD) player, to watch videos that are on a network drive accessible to the computer that runs Serviio.

Transcoding

DLNA devices are supposed to be able to tell Serviio what formats they can handle natively, but some do not, or they do but don't provide enough detail. For example, they might be able to play a certain format, but they don't mention that it's only if the video bitrate is under a certain threshold. Serviio can transcode these unplayable files, and it supports many devices out of the box. Still, you may well have to add custom support for your devices, depending on what you're trying to play.

The transcoding configuration is in device "profiles" in Serviio's profiles.xml file. Nowadays, instead of editing it directly, you create a new file named user-profiles.xml, and put your enhancements in there. The format is the same as for profiles.xml. More info: http://serviio.org/index.php?option=com_content&view=article&id=24

My user-profiles.xml

Here's what I am using currently in my user-profiles.xml.

Samsung BD-C6500 support

To enhance support for my Blu-Ray player, a BD-C6500, which is one of the older Samsung "C" models. As compared to the Samsung B/C profile, which works pretty well, I am adding the following features:

  • Transcode any of the following to an MPEG-TS stream with MPEG-2 video (max. 11 Mbps) + AC-3 audio:
    • Any MPEG-PS (VOB) file containing PCM audio (this player cannot play such audio correctly, at least when streamed)
    • Any file containing DTS audio (this player does its own DTS to DD transcoding if using optical out, but I prefer to do it myself)
    • Any file containing DTS-HD audio (I don't think this player handles it at all)
    • Any file containing H.264 High 4.1 video (probably only 1080p content with bitrates too high to handle)
    • Any file containing H.264 High 4:2:2, 4:4:4, or 10 video (I made some 4:2:2 versions of DV rips)

Some 1080p and even 720p content can still have too-high of bitrate for this player to handle, even if it is not H.264 High 4.1, but Serviio does not yet have a way of matching files based on their bitrate. Matching the codec and profile/level combo is the best we can do.

I am not sure the Detection section I added actually works. I usually just manually select a profile in Serviio Console, and this overrides the detection algorithm.

When transcoding to MPEG, these particular Samsung players do not allow navigating forward and back within the stream.

<Profile id="SamsungBDC6500" name="Samsung BD-C6500" extendsProfileId="7">
	<!--
	The user manual says it supports the following:
		audio file types: MP3, WMA
		video must be 1920x1080 max, but max video bitrate seems to be about 17 Mbps, and at 1080p more like 11 Mbps.
		AVI video: DivX 3.11/4.x/5.1/6.0, XviD, MP4v3, H.264 BP/MP/HP
		AVI audio: MP3, AC3, DTS, WMA, PCM
		MKV video: VC-1 AP, DivX 5.1/6.0, XviD, H.264 BP/MP/HP
		MKV audio: MP3, AC3, DTS
		WMV video: VC-1 AP, VC-1 SM
		WMV audio: WMA
		MP4 video: MP4, H.264 BP/MP/HP
		MP4 audio: AAC
		MPEG-PS/TS video: MPEG1, MPEG2, H.264 BP/MP/HP
		MPEG-PS/TS audio: MP1, MP2, AC3, DTS
	-->
	<Detection>
		<HttpHeaders>
			<User-Agent>.*SEC_HHP_BD-C6500.*</User-Agent>
		</HttpHeaders>
	</Detection>
	  <Transcoding>
		<Video targetContainer="mpegts" targetVCodec="mpeg2video" targetACodec="ac3" aBitrate="448" maxVBitrate="11000" forceVTranscoding="true">
			<Matches container="mpeg" aCodec="lpcm"/>
			<Matches container="*" aCodec="dca"/>
			<Matches container="*" aCodec="dts-hd"/>
			<Matches container="*" aCodec="eac3"/>
			<Matches container="*" vCodec="h264" profile="high" levelGreaterThan="4.0"/>
			<Matches container="*" vCodec="h264" profile="high_422"/>
			<Matches container="*" vCodec="h264" profile="high_444"/>
			<Matches container="*" vCodec="h264" profile="high_10"/>
		</Video>
	  </Transcoding>
</Profile>

Roku Stick support

I have an old Samsung "A" model TV from 2008, and in 2018 I added a Roku Stick to it. I was not having much luck with the Roku profiles that came with Serviio, so I made my own:

<Profile id="RokuStick" name="Roku Media Player on Roku Stick" extendsProfileId="RokuNo4kApp">
	<!--
	Roku Stick (2017 model)

	The help screen in the app says these formats are supported:
	Video(H.264) - MKV, MOV, MP4
	Audio - AAC, MP3, WMA, WAV(PCM), AIFF, FLAC
	Audio - Ogg
	Photo - JPEG, PNG(2Kx2K), GIF(2Kx2K)

	The help screen also says "Dolby Digital is supported via pass through
	on MKV, MP4 and MOV files. DTS is supported via pass through on MKV."

	If it cannot play a file under any circumstances, the file won't show up
	in the app. So if you see the file, the app will at least feed the file
	to the Roku Stick. However, the Roku Stick's settings may interfere with
	the transmission to the next device in the chain. Also, that device may
	not like what it gets.

	In my case, the Roku Stick is plugged into a TV, a 2008 Samsung "A" model
	with no audio configuration options to speak of. The Roku Stick has 2 audio
	settings:
	  Audio mode (Stereo or Auto)
	  HDMI (Auto, PCM-Stereo, Dolby D, Dolby D+, Dolby D & DTS, or Dolby D+ & DTS).

	What you choose for HDMI affects what the Auto setting under Audio mode chooses.
	If both are on Auto, and the TV's optical audio out is not connected to
	anything, then the audio mode will be Auto (Stereo). But if I set HDMI to
	something else, then the audio mode is Auto (whatever I chose).

	If the audio mode is Stereo, the audio stream sent in video must be AAC or MP3.
	Other formats like AC-3 or PCM will be silent.

	If the audio mode includes DD, then AC-3 is supported.
	Presumably E-AC-3 is supported if the audio mode includes DD+.

	However if the audio mode includes DTS, it does not result in DTS audio
	working for me. It is still silent. I think the TV just does not like it.

	Audio in a video can be LPCM, but audio files transcoded to LPCM are not
	supported by the Roku; they don't show up at all, so you have to transcode
	them to MP3 instead.
	-->
	<Transcoding>
		<Video targetContainer="mpegts" targetVCodec="h264">
			<Matches container="*" vCodec="mpeg4" aCodec="aac"/>
			<Matches container="*" vCodec="mpeg4" aCodec="mp3"/>
			<Matches container="*" vCodec="msmpeg4" aCodec="aac"/>
			<Matches container="*" vCodec="msmpeg4" aCodec="mp3"/>
			<Matches container="flv" aCodec="aac"/>
			<Matches container="flv" aCodec="mp3"/>
		</Video>
		<Video targetContainer="mpegts" targetVCodec="h264" targetACodec="ac3" aBitrate="448">
			<Matches container="*" aCodec="dca"/>
			<Matches container="*" aCodec="dts-hd"/>
			<Matches container="*" aCodec="flac"/>
			<Matches container="*" vCodec="wmv2"/>
			<Matches container="*" vCodec="mpeg1video"/>
			<Matches container="*" vCodec="mpeg2video"/>
			<Matches container="avi"/>
			<Matches container="flv"/>
			<Matches container="mpeg"/>
			<Matches container="mpegvideo"/>
			<Matches container="wtv"/>
		</Video>
		<Audio targetContainer="mp3" aBitrate="320">
			<Matches container="ape"/>
		</Audio>
	</Transcoding>
</Profile>

Dish Hopper support

Here's what I added to create a profile matching the Dish Hopper:

<Profile id="Hopper" name="Dish Hopper" extendsProfileId="1">
	<!--
	video: mp2t, mp1s, mpeg2, mp4, x-matroska
	audio: mpeg, mpeg3, mp3, mp4, mp4-latm
	image: jpeg

		Does support AAC audio in a video stream.
		If multiple audio streams, only the last one is played.
		If an MJPEG stream exists (e.g. for thumbnail), file will not play.
		Image slideshow is broken (as of May 2018); you can view 1 at a time though.
		Does not support H.264 in an MPEG-TS stream, so must transcode to MPEG-2 video.
	-->
	<Detection>
		 <UPnPSearch>
			<ModelName>Hopper</ModelName>
			<Manufacturer>Echostar</Manufacturer>
		 </UPnPSearch>
	</Detection>
	<Transcoding>
		<Video targetContainer="mpegts" targetVCodec="mpeg2video" maxVBitrate="15000" maxHeight="720">
			<Matches container="*" vCodec="h264" levelGreaterThan="4.1" aCodec="aac"/>
			<Matches container="*" vCodec="h265" levelGreaterThan="4.1" aCodec="aac"/>
		</Video>
		<Video targetContainer="mpegts" targetVCodec="mpeg2video" maxVBitrate="15000">
			<!-- unsupported video with AAC or MP3 audio: transcode video only -->
			<Matches container="*" vCodec="h264" levelGreaterThan="4.1" aCodec="aac"/>
			<Matches container="*" vCodec="h264" profile="high_422" aCodec="aac"/>
			<Matches container="*" vCodec="h264" profile="high_444" aCodec="aac"/>
			<Matches container="*" vCodec="h264" profile="high_10" aCodec="aac"/>
			<Matches container="*" vCodec="h265" aCodec="aac"/>
			<Matches container="*" vCodec="mpeg4" aCodec="aac"/>
			<Matches container="*" vCodec="mpeg4" aCodec="mp3"/>
			<Matches container="avi" aCodec="aac"/>
			<Matches container="avi" aCodec="mp3"/>
			<Matches container="flv" aCodec="aac"/>
			<Matches container="flv" aCodec="mp3"/>
			<!--
			not working; see http://forum.serviio.org/viewtopic.php?f=7&t=24545
			<Matches container="mp4" vFourCC="cvid,svq1,svq3" aCodec="aac"/>
			<Matches container="mp4" vFourCC="cvid,svq1,svq3" aCodec="mp3"/>
			-->
		</Video>
		<Video targetContainer="mpegts" targetVCodec="mpeg2video" maxVBitrate="15000" targetACodec="ac3" aBitrate="448">
		 	<Matches container="*" aCodec="dca"/>
		 	<Matches container="*" aCodec="dts-hd"/>
		 	<Matches container="*" aCodec="eac3"/>
			<Matches container="*" aCodec="lpcm"/>
			<Matches container="*" vCodec="dvvideo"/>
			<Matches container="*" vCodec="h264" levelGreaterThan="4.1"/>
			<Matches container="*" vCodec="h264" profile="high_422"/>
			<Matches container="*" vCodec="h264" profile="high_444"/>
			<Matches container="*" vCodec="h264" profile="high_10"/>
			<Matches container="*" vCodec="h265"/>
			<Matches container="*" vCodec="mpeg4"/>
			<Matches container="*" vCodec="theora"/>
			<Matches container="*" vCodec="wmv2"/>
			<Matches container="avi"/>
			<Matches container="flv"/>
			<!--
			not working; see http://forum.serviio.org/viewtopic.php?f=7&t=24545
			<Matches container="mp4" vFourCC="cvid,svq1,svq3"/>
			-->
		</Video>
		<Audio targetContainer="mp3" aBitrate="320">
			<Matches container="ape"/>
			<Matches container="flac"/>
			<Matches container="lpcm"/>
			<Matches container="ogg"/>
		</Audio>
	  </Transcoding>
</Profile>

H.264 levels above 3.1 can exceed 17 Mbps and 480p. Ideally we would only transcode those videos which actually need it, based on bitrate, but Serviio does not make this possible. So the question is, do you transcode all H.264 files above level 3.1, including those with lower bitrates which would play OK normally, or do you pick a higher level like 4.0 or 4.1 because those are more likely to have higher bitrates, taking the risk that some of your vids which need to be transcoded will not be? I am going with a 4.1 cutoff for now, and will see how it does.

nPlayer on iPad support

On iOS devices like the iPad or iPhone, there are various apps you can use as DLNA renderers. The iPad can even output HDMI via an adapter.

On a first-generation iPad, your options for free are quite limited. I found that the non-free but cheap nPlayer app works very well. It plays almost every format natively, so the default profile in Serviio works well enough.

I tried to make a profile for the few formats that have trouble, but I can't get Serviio to select the profile. I asked about it in the forum.

<Profile id="nPlayer-iPad1" name="nPlayer on iPad (1st Gen)" extendsProfileId="1">
	<!--
		This profile is useless!

		nPlayer does not respond to UPnP M-SEARCH requests, so Serviio does not know it is out there.
		Although requests come in with a "User-Agent: nPlayer/3.0" header, this profile does not match it. Why?
		nPlayer does not show up as a connected device in Serviio Console, so you can't manually select this profile.

		Working video:
			containers: MKV, MP4, AVI, MPEG-TS, MPEG-PS
			video codecs: H.264 up to High L5, MPEG-1, MPEG-2, MPEG4, VP6, WMV, MJPEG
			audio codecs: AC-3, AAC, MP2, MP3, WMA, PCM, ADPCM(CCITT)

		Non-working video codecs:
			H.263 does not show up when browsing.
			H.264 High L5.1 has no picture.
			H.264 High422 works but drops too many frames on this iPad (even at 480p 24fps).
			H.265 Main 10 L3.1 (at 480p 60fps) and L4 (at 1080p 24fps) stutters & drops many frames.

		Working audio:
			containers: FLAC, MP3

		Non-working audio:
			containers: APE
	-->
	<Detection>
		<HttpHeaders>
			<User-Agent>.*nPlayer.*</User-Agent>
		</HttpHeaders>
	</Detection>
	<Transcoding>
		<Video targetContainer="mpegts" targetVCodec="h264">
			<Matches container="*" vCodec="h263"/>
			<Matches container="*" vCodec="h264" levelGreaterThan="5.0"/>
			<Matches container="*" vCodec="h264" profile="high_422"/>
			<Matches container="*" vCodec="h264" profile="high_444"/>
			<Matches container="*" vCodec="h264" profile="high_10"/>
			<Matches container="*" vCodec="h265" profile="high_10"/>
		</Video>
		<Audio targetContainer="lpcm">
			<Matches container="ape"/>
		</Audio>
	</Transcoding>
</Profile>

Logitech Media Server and Squeezebox Boom support

I don't think I will be using LMS or my Squeezebox Boom to access audio via DLNA devices, but if I ever do, here is what each supports (as reported by UPnP Spy):

Logitech Media Server:

http-get:*:audio/L16;rate=44100;channels=2:DLNA.ORG_PN=LPCM,
http-get:*:audio/mp4:DLNA.ORG_PN=AAC_ISO;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000,
http-get:*:audio/mp4:DLNA.ORG_PN=AAC_ISO_192;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000,
http-get:*:audio/mp4:DLNA.ORG_PN=AAC_ISO_320;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000,
http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=11;DLNA.ORG_FLAGS=01700000000000000000000000000000,
http-get:*:audio/mpeg:DLNA.ORG_PN=MP3X;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000,
http-get:*:audio/x-ms-wma:DLNA.ORG_PN=WMABASE;DLNA.ORG_OP=11;DLNA.ORG_FLAGS=01700000000000000000000000000000,
http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_TN;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=00f00000000000000000000000000000,
http-get:*:image/png:DLNA.ORG_PN=PNG_TN;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=00f00000000000000000000000000000,
http-get:*:audio/mp4:*,
http-get:*:audio/mpeg:*,
http-get:*:audio/x-flac:*,
http-get:*:audio/x-m4a-lossless:*,
http-get:*:audio/x-ogg:*

Squeezebox Boom:

http-get:*:audio/mpeg:*,
http-get:*:audio/L16;rate=8000;channels=1:*,
http-get:*:audio/L16;rate=8000;channels=2:*,
http-get:*:audio/L16;rate=11025;channels=1:*,
http-get:*:audio/L16;rate=11025;channels=2:*,
http-get:*:audio/L16;rate=12000;channels=1:*,
http-get:*:audio/L16;rate=12000;channels=2:*,
http-get:*:audio/L16;rate=16000;channels=1:*,
http-get:*:audio/L16;rate=16000;channels=2:*,
http-get:*:audio/L16;rate=22050;channels=1:*,
http-get:*:audio/L16;rate=22050;channels=2:*,
http-get:*:audio/L16;rate=24000;channels=1:*,
http-get:*:audio/L16;rate=24000;channels=2:*,
http-get:*:audio/L16;rate=32000;channels=1:*,
http-get:*:audio/L16;rate=32000;channels=2:*,
http-get:*:audio/L16;rate=44100;channels=1:*,
http-get:*:audio/L16;rate=44100;channels=2:*,
http-get:*:audio/L16;rate=48000;channels=1:*,
http-get:*:audio/L16;rate=48000;channels=2:*,
http-get:*:audio/vnd.dlna.adts:*,
http-get:*:audio/vnd.dlna.adts:*,
http-get:*:audio/mp4:*,
http-get:*:audio/mp4:*,
http-get:*:audio/mp4:*,
http-get:*:audio/x-ms-wma:*,
http-get:*:audio/x-ms-wma:*,
http-get:*:audio/x-ms-wma:*,
http-get:*:application/ogg:*,
http-get:*:audio/x-flac:*

Transcoding interlaced video

Serviio does not know how to recognize interlaced video, so it does not invoke FFmpeg with the correct parameters for transcoding it. The resulting progressive video sometimes appears jumpy/jittery because the interlacing wasn't taken into account during transcoding.

The developer has said that part of the problem is that ffmpeg -i does not reliably report whether video is interlaced. He's right; a container may have metadata saying the video is interlaced when it actually is not. Or it may only be partially interlaced. Or it may be interlaced but the container makes no mention of it.

Still, I think it would be nice if Serviio would just trust the metadata when it does happen to say the video is interlaced, i.e. when ffmpeg -i mentions "bottom first" or "top first". If the metadata is wrong or missing, this is a "not my problem" kind of problem.

Example:

Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bottom first), 720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc

In the meantime, you have to just transcode such files yourself.

Unfortunately, this metadata is not always present, e.g. this DV video is interlaced, bottom first, but you wouldn't know it by the ffmpeg -i output:

Stream #0:0: Video: dvvideo (dvsd / 0x64737664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], 28778 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc

Somehow, MediaInfo reads something in this same file to know whether it is interlaced and which field is first. Why can't FFmpeg do this?

Well anyway, you have to transcode these files yourself, for now.

In FFmpeg, -deinterlace works, but is deprecated and is now just an alias for -vf yadif. This produces deinterlaced output at the input framerate. Alternatively, -flags +ilme+ildct also works. If the input and output are both MPEG-2 (e.g. VOB files), this produces interlaced output which can be played natively.

Java updates

In the past, I had to completely shut down Serviio before updating Java (64-bit). See my notes on Java updates for more info.

Lately, I have not even had the 64-bit version of Java installed, and Serviio and Java both update just fine. *shrug*

Serviio disappeared after router change

After replacing my WiFi router with an AirPort Time Capsule, Serviio on my Win7 PC was no longer seen by my BD player. Serviio running on a Mac on the same network had no problem. Both computers are using a wired connection to the router. Disabling firewalls on the PC didn't make a difference. I eventually figured out a solution, but didn't make a note of what it was. Oh well.