Serviio - free DLNA media server for Windows, Mac and Linux

Media Streaming Server

Transcoding configuration

Transcoding configuration is set up per renderer profile in profiles.xml. There are three types of transcoding. General transcoding of files (Transcoding element), additional transcoding of online files (OnlineTranscoding element) and transcoding used for burning-in subtitles (HardSubsTranscoding element).

Generally, a local file is transcoded if there is a Transcoding or HardSubsTranscoding configuration for it. An online file is transcoded if there is an OnlineTranscoding or (local) transcoding matching it. Generic profile doesn't transcode any local media files, unless they require hardsubs transcoding. Serviio comes with some profiles per-defined but it really is up to the community to create their own configurations for different devices.

Inheritance

Transcoding definitions have a particular rules for inheritance. In the case of OnlineTranscoding and HardSubsTranscoding, if the block is present in the parent profile and child profile doesn't have one, the whole block is inherited. This is not the case with (local) Transcoding block, which is never inherited as a whole.

Each Video or Audio element within a transcoding configuration (both local and online) can be marked for inheritance via forceInheritance attribute. If that is present the particular configuration part will be added to the child's transcoding configuration (with lowest priority, i.e. at the end of configuration list).

An example of transcoding inheritance


    <Profile id="1">
      <Transcoding (A)>
        <Video (A)>
      </Transcoding (A)>
      <OnlineTranscoding (A)>
        <Video (A)>
      </OnlineTranscoding (A)>
      <HardSubsTranscoding (A)>
        <Video (A)>
      </HardSubsTranscoding (A)>
    </Profile>

    <Profile id="2" extendsProfileId="1">
      <Transcoding (B)>
        <Video (B)>
      </Transcoding (B)>
    </Profile>

This will result in profile 2 having it's own local transcoding config (B) and parent's OnlineTranscoding and HardSubsTranscoding config (A).


    <Profile id="1">
      <Transcoding (A)>
        <Video (A) forceInheritance="true">
      </Transcoding (A)>
      <OnlineTranscoding (A)>
        <Video (A)>
      </OnlineTranscoding (A)>
      <HardSubsTranscoding (A)>
        <Video (A)>
      </HardSubsTranscoding (A)>
    </Profile>

    <Profile id="2" extendsProfileId="1">
      <Transcoding (B)>
        <Video (B)>
      </Transcoding (B)>
      <OnlineTranscoding (B)>
        <Video (B)>
      </OnlineTranscoding (B)>
      <HardSubsTranscoding (B)>
        <Video (B)>
      </HardSubsTranscoding (B)>
    </Profile>

This will result in profile 2 having it's own local transcoding config (B) and additional Video config (A) added to it. It'll also have its own OnlineTranscoding and HardSubsTranscoding config (B) without any input from the parent's OnlineTranscoding / HardSubsTranscoding.

Setting up local transcoding

Transcoding configuration is defined in profiles.xml file, per renderer profile. These are the available elements to use:

Transcoding - parent of transcoding configuration

Video transcoding

Video - defines video transcoding definitions; can be one or more, with the elements order being taken in consideration (the first definition that matches a file is used)

Attributes:

  • targetContainer - compulsory; name of container to transcode into; possible values: asf, mpeg (MPEG2PS), mpegts (MPEG2TS), applehttp (HLS)
  • targetVCodec - optional; name of video codec to transcode into or omit this attribute to keep the video stream as it is; possible values: mpeg2video (MPEG2), wmv2 (WMV9), h264
  • targetACodec - optional; name of audio codec to transcode into or omit this attribute to keep the audio stream as it is; possible values: aac, ac3, mp2, mp3, lpcm, wmav2
  • maxVBitrate - optional; max. video bitrate [kbit/sec] or omit to keep the same quality
  • aBitrate - optional; audio bitrate [kbit/sec] to use when transcoding audio track, default is 192
  • aSamplerate - optional; audio sample rate [Hz] to use when transcoding audio track, default is 48000
  • forceVTranscoding - optional; if true, the video stream will always be transcoded even in cases when in could just be rewrapped; default is false
  • forceStereo - optional; if true, audio transcoding involves forcing number of channels to 2; default is false
  • maxHeight - optional; limits transcoded video height to this value. It will cause video transcoding (similar to forceVTranscoding)
  • DAR - optional; forces the output video to the given display aspect ratio; possible values: 16:9
  • forceInheritance - optional; defines whether this transcoding configuration is inherited by child profile

Matches - specifies which media files will fall into a transcoding configuration and will therefore be processed by the transcoding engine; can be one or more, with the elements order being taken in consideration (the first matcher that fits a file is used)

Attributes:

  • container - compulsory; name of container; possible values: * (any), asf (WMV), mpeg (MPEG2PS), mpegts (MPEG2TS), mp4 (MPEG4, MOV), mjpeg, mpegvideo (MPEG1), matroska (MKV), avi, flv, wtv, ogg, 3gp, rtp, rtsp, applehttp, rm (RealMedia)
  • vCodec - optional; name of video codec of the original file or omit to transcode any video codec in the container; possible values: mpeg2video, mpeg1video, wmv2, mpeg4, msmpeg4, h263, h264, h265, vc1, mjpeg, flv, vp6, vp8, vp9, theora, dvvideo, rv
  • aCodec - optional; name of audio codec of the original file or omit to transcode any audio codec in the container; possible values: aac, ac3, eac3, mp3, mp2, lpcm, wmav2, wmapro, dca (DTS), dts-hd, flac, vorbis, truehd, amrnb, real, speex
  • profile - optional; H264 profile (in a case of H264 video stream); possible values: baseline, c_baseline, main, extended, high, high_422, high_444, high_10
  • levelGreaterThan - optional; H264 level (in a case of H264 video stream, in combination with profile attribute); possible values: level number, e.g. 4, 4.1, 5, etc.
  • ftypNotIn - optional; a comma separated list of mp4 major brands (ftyp)
  • vFourCC - optional; a comma-separated list of FourCC video codec codes to match against
  • squarePixels - optional; if true, matches videos with SAR (sample/pixel aspect ratio) of 1:1
  • aMultichannel - optional; if true, matches videos with multichannel (moe than 2 channels) audio

Audio transcoding

Audio - defines audio transcoding definitions; can be one or more, with the elements order being taken in consideration (the first definition that matches a file is used)

Attributes:

  • targetContainer - compulsory; name of container to transcode into; possible values: lpcm, mp3
  • aBitrate - optional; audio bitrate [kbit/sec] to use for transcoding, default is 192
  • aSamplerate - optional; audio sample rate [Hz] to use when transcoding audio track, default is 48000
  • forceInheritance - optional; defines whether this transcoding configuration is inherited by child profile

Matches - specifies which media files will fall into a transcoding configuration and will therefore be processed by the transcoding engine; can be one or more, with the elements order being taken in consideration (the first matcher that fits a file is used)

Attributes:

  • container - compulsory; name of container; possible values: * (any), mp4, asf, mp3, mp2, lpcm, flac, ogg, flv, rtp, rtsp, adts, wv, mpc, ape, dsf
  • codec - optional; codec of the audio stream; possible values: alac, wmalossless, wmapro

Image transcoding

Image - defines image transcoding definitions; can be one or more, with the elements order being taken in consideration (the first definition that matches a file is used)

Attributes:

  • forceInheritance - optional; defines whether this transcoding configuration is inherited by child profile

Matches - specifies which media files will fall into a transcoding configuration and will therefore be processed by the transcoding engine; can be one or more, with the elements order being taken in consideration (the first matcher that fits a file is used)

Attributes:

  • container - compulsory; name of container; possible values: jpeg, raw
  • subsampling - optional; chroma subsampling; possible values: YUV444, YUV422, YUV420, YUV411

Setting up online transcoding

Online transcoding configuration is defined in profiles.xml file, per renderer profile and is inherited from parent profile (as a whole). These are the available elements to use:

OnlineTranscoding - parent of online transcoding configuration. It includes the same sub element (with the exception of Matches) as transcoding above.

Attributes:

keepStreamOpen - optional; specifies whether transcoded stream should be kept open for a period of time for possible future incoming requests; default true

Matches - Includes the same attributes as Matches of respective local audio/video Matches elements, with the addition of:

Attributes:

  • contentType - optional; type of online content; possible values: vod (non-live-stream online content), live (live stream), any; default is 'any'

Setting up hardsubs transcoding

Hardsubs transcoding configuration is defined in profiles.xml file, per renderer profile and is inherited from parent profile (as a whole). These are the available elements to use:

HardSubsTranscoding - parent of hardsubs transcoding configuration. It includes a single Video element (with the same attributes as local Transcoding). The Video element doesn't include any matches sub-elements, as it matches all content by default.

Examples of transcoding configurations

There are two way how to get content your device doesn't support to play on it:

  • rewrapping (remuxing) the data streams into a different container
  • transcoding data streams using a different codec

Rewrapping media files

If the device supports audio or video stream but not the container file it's much better to set up only remuxing the streams into a different container. That will result in low CPU usage and no quality loss of the streams. Example might be remuxing MKV file with H264 video and aac audio into mpeg2ts file. The audio and/or video streams stay the same, only the container changes.

Example of a light-weight transcoding (only audio track) configuration is below. This configuration is not CPU intensive, because audio transcoding doesn't require much resources and the video stream is reused as is (no targetVCodec is defined).


<Transcoding>   
 <Video targetContainer="mpegts" targetACodec="lpcm">
  <Matches container="matroska" aCodec="dca"/>
 </Video>
</Transcoding>

It means: transcode matroska files with DTS audio track into MPEG2 TS with LPCM track, but keep the video stream whatever it is (probably H264). All other matroska files will be played in their native format.

Transcoding media files

Sometimes remuxing is not the option. It is the case mainly when the audio/video stream codec is not supported by the player at all. The stream(s) will have to be transcoded (possible quality loss) into a different format. This also involves a lot of CPU time, especially when handling HD content. An example might be transcoding MPG4 with H264 video content into ASF container including WMV9 video.


<Transcoding>
 <Video targetContainer="asf" targetVCodec="wmv2" targetACodec="wmav2" maxVBitrate="15360">
  <Matches container="matroska" />
  <Matches container="mpeg" />
  <Matches container="mpegvideo" />
 </Video>
</Transcoding>

This example means: transcode all mpeg1, mpeg2ps and matroska files into asf file with wmv video codec, wma audio codec and max. video bitrate of 15360 kbit/sec.

By adding the following snippet we also define mpeg2ts files with aac audio codec (video codec doesn't matter) to use another target file format:


<Video targetContainer="mpeg" targetVCodec="mpeg2video" targetACodec="ac3">
  <Matches container="mpegts" aCodec="aac"/>
</Video>