Difference between revisions of "User:Mjb/Serviio"

From Offset
Jump to navigationJump to search
(Transcoding)
(Java updates)
Line 129: Line 129:
  
 
We could also use maxHeight="720" for speed and quality, sacrificing detail and ensuring 1080p is never seen, but it doesn't work well with 90-degree rotated video and may not be necessary anyway.
 
We could also use maxHeight="720" for speed and quality, sacrificing detail and ensuring 1080p is never seen, but it doesn't work well with 90-degree rotated video and may not be necessary anyway.
 +
 +
==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 <code>ffmpeg -i</code> 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 <code>ffmpeg -i</code> mentions "bottom first" or "top first". If the metadata is wrong or missing, this is a "not my problem" kind of problem.
 +
 +
Example:
 +
 +
<pre>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</pre>
 +
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 <code>ffmpeg -i</code> output:
 +
 +
<pre>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</pre>
 +
 +
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, <code>-deinterlace</code> works, but is deprecated and is now just an alias for <code>-vf yadif</code>. This produces deinterlaced output at the input framerate. Alternatively, <code>-flags +ilme+ildct</code> 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==
 
==Java updates==

Revision as of 07:06, 8 May 2018

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.

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.

Transcoding

DLNA devices are supposed to be able to tell Serviio what formats they can handle, but my BD player does not really do a good job of this. If the bitrate is too high or the format is unrecognized, the file won't play. Serviio can transcode these files, though.

The transcoding configuration is in Serviio's profiles.xml file. Nowadays, instead of editing it directly, you are supposed to 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">
      <!-- Supposedly these are what it supports:
           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="*" 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>

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

        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.
	-->
      <Detection>
         <UPnPSearch>
            <ModelName>Hopper</ModelName>
            <Manufacturer>Echostar</Manufacturer>
         </UPnPSearch>
      </Detection>
      <Transcoding>
         <Video targetContainer="mpegts" targetVCodec="mpeg2video" targetACodec="ac3" aBitrate="448" maxVBitrate="15000">
            <Matches container="*" aCodec="lpcm"/>
         	<Matches container="*" aCodec="dca" />
         	<Matches container="*" aCodec="dts-hd" />
            <!--it also does not play E-AC-3 but there's no way to match that without matching AC-3-->
            <Matches container="*" vCodec="h265" />
            <Matches container="*" vCodec="h264" profile="high_422"/>
            <Matches container="*" vCodec="h264" profile="high_444"/>
            <Matches container="*" vCodec="h264" profile="high_10"/>
            <Matches container="*" vCodec="mpeg4"/>
            <Matches container="*" vCodec="theora"/>
            <Matches container="*" vCodec="dvvideo" />
            <Matches container="avi"/>
            <Matches container="flv"/>
        </Video>
         <Audio targetContainer="mp3" aBitrate="320">
            <Matches container="ape"/>
            <Matches container="flac"/>
            <Matches container="lpcm"/>
            <Matches container="ogg"/>
         </Audio>
      </Transcoding>
</Profile>

This may still need some work.

HD video (720p or 1080p) can be very demanding. We can transcode to H.264, but the Hopper does not seem to be willing to accept H.264 in an MPEG-TS stream. Besides, Serviio defaults its H.264 transcoding to Baseline L3, designed for (max.) 480p @ 10 Mbps, and it uses FFmpeg's -crf 25 setting, which is just too low -quality for anything HD. Another drawback is that at 1080p, even using a relatively fast computer, H.264 encoding is sometimes just too slow for streaming.

So for now, we instead use mpeg2video. It defaults to Main @ High 1440, designed for (max.) 720p @ 60 Mbps. This converts much faster, and 1080p works well enough with these settings.

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 as mentioned above, 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'm trying a higher cutoff for now, but may have to switch to lower ones in the future, e.g.:

	  <Matches container="*" vCodec="h264" profile="high" levelGreaterThan="3.1" />
	  <Matches container="*" vCodec="h264" profile="main" levelGreaterThan="3.1" />
	  <Matches container="*" vCodec="h264" profile="c_baseline" levelGreaterThan="3.1" />
	  <Matches container="*" vCodec="h264" profile="baseline" levelGreaterThan="3.1" />

We could also use maxHeight="720" for speed and quality, sacrificing detail and ensuring 1080p is never seen, but it doesn't work well with 90-degree rotated video and may not be necessary anyway.

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

Completely shut down Serviio before updating Java. See my notes on Java updates for more info.