# Stream

# Input

# Protocols

# UDP

Syntax: udp://hostname:port[?options]

options:

localaddr=addr Local IP address of a network interface used for sending packets or joining multicast groups.

# RTP

Syntax: udp://hostname:port[?options]

options:

localaddr=addr Local IP address of a network interface used for sending packets or joining multicast groups.

# RTSP

Syntax: rtsp://hostname[:port]/path

# RTMP

Syntax: rtmp://[username:password@]server[:port][/app][/instance][/playpath]

# HLS, HTTP-TS

Syntax: HTTP or HTTPS URL

HTTP-TS Source From Astra

If your source stream is HTTP-TS from astra, they are using 1 MiB buffer size in default for HTTP-TS output, and it will close the HTTP connection if the buffer overflow. This is very common problem that you see the HTTP-TS streams are keep restarting in the X Acceleration Codec panel. You need go to the Astra > General setting page, and set the HTTP Output Buffer option to a large value, recommend 20000, which is 20 MiB.

But the Astra general settings does not always working, in this case, you can go to the Astra channel settings page, and add the output with buffer_size option manually. for example: In Astra channel settings page, add output: http://0.0.0.0:port#buffer_size=20000. Then in the X Acceleration Codec stream settings page, use URL http://astra-ip:port in the Source Stream.

# Video4Linux2

Syntax: v4l2:///dev/videoX or v4l2:///dev/videoX&alsa=Y

X The video device number, it's start from 0. Y The ALSA device number. it's like hw:0,0

TIP

If you are using 4.x or above kernel, the panel will automatically find the corresponding alsa device for you. So you can simply use first syntax.

# Youtube, Twitch

Syntax: Youtube/Twitch Play Page URL

TIP

We are using the Youtube-dl plugin internal, so not just Youtube, Twitch, other website are supported too. You can check the supported website here: http://ytdl-org.github.io/youtube-dl/supportedsites.html (opens new window)

# DVB

Syntax: dvb://server=X&adapter=Y&sid=Z[&softcam=M]

X is the server ID, Y is the adapter ID, Z is the channel SID, M is the softcam ID.

TIP

The softcam option is optional, the panel will find the corresponding softcam to decryption. However, if you want to force the channel to use specified softcam, you can specify it in the URL.

# Backup URLs

We supports up to 20 backup URLs for the source stream, and you can click the icon at right of Source Stream option for open the collapsed URLs.

URL Priority

The URL priority is #1 > #2 > #3 ... > #20, lower number has higher priority. When URL #1 is offline, it will trying the URL #2 and URL #3, util one of backup URL is online. Also, it will switch to the higher priority URL if they are back to online. The panel will check the URL status for every 60 seconds.

# DRM Decryption

If you have channels are DASH, HLS or Smooth Streaming in DRM encrypted format, you can add the URL parameter decryption_key=KID:KEY,KID:KEY... to the source stream URL. Then xaccel panel will use the keys you provided to decrypt the channels.

# Examples

https://....mpd?decryption_key=KEY
https://....mpd?decryption_key=KID:KEY
https://....mpd?decryption_key=KID:KEY,KID:KEY
https://....mpd?...&decryption_key=KID:KEY,KID:KEY
https://....m3u8?decryption_key=KID:KEY,KID:KEY
https://....isml/manfest?decryption_key=KID:KEY,KID:KEY

TIP

  • If the channel has only one decryption key, you can ignore the kid.
  • If the source stream URL has other URL parameters already, you need append &decryption_key=KID:KEY,KID:KEY to the end of URL. Otherwise use ?decryption_key=KID:KEY,KID:KEY.
  • Multiple decryption keys are supported after 4.5.6.
  • Smooth Streaming and HLS DRM decryption are supported after v4.6.0.
  • Check this release page see how to upgrade to the latest

Update Decryption Keys

Since the 4.7.9 version panel, we added the decryption_key detection supports in url redirection. If you have php program to handle the source stream URL, you can simply update the decryption_key=kid:key,kid:key in the redirection URL. The backend ffmpeg will update the decryption key automatically. This way no need restart the stream.

# Stream Import

We supports mass import the stream from m38, m3u8 suffixed M3U playlist or zip suffixed Xtream / Xtream UI backup, or json format file. You can go to Tools > Stream Import for upload the file and import.

# Example JSON File Format

[
    {
        "channel_name": "Channel 1",
        "mpd_url": "https://example.com/channel1.mpd",
        "key": "KID:KEY",
        "useragent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
    },
    {
        "channel_name": "Channel 2",
        "mpd_url": "https://example.com/channel2.mpd",
        "keys": [
            {"kid": "KID1", "key": "KEY2"},
            {"kid": "KID2", "key": "KEY2"},
            {"kid": "KID3", "key": "KEY3"}
        ],
        "useragent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
    }
]

TIP

  • Import JSON File feature is added in v4.7.11.

# Movies To Live

If you need convert movie files to the live stream, you can use following steps to achieve it:

  1. Upload the movie files to the xaccel panel installed server, assume you are upload to /root/movies/.
  2. Create a txt file, for example: /root/my-live-stream.txt. Then you need fill the movie files's path to this txt file, the txt file content should like this:
file '/root/movies/a.mp4'
file '/root/movies/b.mp4'
file '/root/movies/c.mp4'
  1. Use the txt file path /root/my-live-stream.txt in theSource Stream option, and set up the Rate Emulation option to Yes.

# Movies To Movies

If you need transcoding or remuxing the local disk's movie files, here is the steps:

  1. Put the movies files in a local disk directory.
  2. Go to xaccel panel, click Stream > Add Stream tab for create a new stream.
  3. Fill the movie files path in the Source Stream option.
  4. Create a File output, fill the Path and Filename, and the Filename option must contains {filename} for specify the filename pattern of output movies.

# HTTP Input Options

If your URL is start with http:// or https:// prefix, you can click the icon at right of Source Stream option for open the collapsed HTTP options.

  • HTTP User Agent Set up the HTTP User-Agent in the request header.

  • HTTP Referer Set up the HTTP Referer in the request header.

  • HTTP Proxy Set up the HTTP proxy for the request.

TIP

The HTTP Proxy option supports multiple proxies after v4.5.6 version, you can use comma , to concat it. For example: http://proxy1:port,http://proxy2:port,http:proxy3:port. It will check the proxy status every time the stream starting, and select the working proxy to use.

# Advanced Input Options

# Format Flags

Please make sure you understand the flags before enable it, especially for genpts, igndts and sortdts flags, enable it for a normal stream may cause bad result.

  • discardcorrupt Discard bad or corrupted packets.
  • genpts Generate missing PTS if DTS is present.
  • igndts Ignore DTS if PTS is set. Inert when nofillin is set.
  • sortdts Try to interleave output packets by DTS. At present, available only for AVIs with an index.
  • nobuffer Reduce the latency introduced by buffering during initial input streams analysis.

# Rate Emulation

This option is for control and limit the stream speed to 1x, and it should only be set up to Yes when stream source is from video file.

# Restream

If you want to restream the channel without transcoding. You can go to the Stream Settings page and set up the Video Encoders, Audio Encoders and Subtitle Encoder option to copy. And we recommend you set up the Video Sync Method option to Pass Through for prevent the audio out of sync and MPEG-TS 26.5 hours problem.

# Transcoding

# Hardware Acceleration

Currently, we supports Intel QuickSync and Nvidia NVENC GPU for hardware acceleration. For QuickSync, you need the Intel CPU with Integrated Graphics Card supports. For NVENC, you need the Nvidia GPU with NVENC chips supports. If you have above hardware acceleration devices are available, you should see some QuickSync or NVENC codec in the Video Encoders's codec option.

For enabled the hardware acceleration, you can set up the Video Encoder's codec option to NVENC or QuickSync codec. Also, there are a few hardware acceleration related options:

  • Hardware Acceleration Device This is for specify which device to be used for transcoding the stream.

  • Hardware Acceleration Method This for control the hardware acceleration should be applied to decoding, encoding or both. we recommend you to use full as always.

For 4K Source

Usually the 4K source is using yuv420p10le pixel format, the GPU may not able to decoding it. In this case, we recommend you to set up the Hardware Acceleration Method to enconding only and Video Pixel Format option to yuv420p.

# Video Encoding

You can go to the Stream Settings page and set up the Video Encoders's codec and bitrate options for enable the transcoding. We currently supports CBR and VBR for the bitrate control, I recommend you use CBR if you have limited bandwidth, or use VBR if you need get better video quality.

  • Video Preset This option is for control to use more CPU/GPU to encoding for get better quality, or use less CPU/GPU to get higher performance. If you want to max the transcoding performance, use Ultrafast or High Performance, or use Slow if you want to max the encoding quality, Otherwise, use default Medium is okay.

  • Video Profile This option is for control the encoder features. Usually we want to enable all good encoder features for get better quality with lowest bitrate. But not all features the decoder supports it, especially if you want to play the stream on mobile or old STB. I recommend you use default High settings for H264 or Main for HEVC.

  • Video Level This option is very similar to the Video Profile. I always recommend you use Auto.

  • Video Framerate This option for specify the output frame rate. It's Auto in default, this means it won't change the frame rate, if source stream is 25 fps, then output will be 25 fps.

  • Keyframe Interval This option is for control how often a keyframe (i-frame) is created in the video. It's 250 frames in default. If your stream is 25 fps output, it means create a keyframe for every 10 seconds.

  • Video Pixel Format This option is for specify the video pixel format to be used for encoding. It's Auto in default, it means won't change the video pixel format.

  • Display Aspect Ratio This option is for specify the video's display aspect ratio. It's Auto in default, it means it won't change it.

TIP

  • If you use libx264 or libx265 codec for CPU based transcoding and CPU usage is high, you can set up the Video Preset option to Superfast or Ultrafast for decrease the CPU usage.

  • If you want to decrease the latency or have delayed picture problem when playing in some STB, set up the Video Framerate option to 2 times of output frame rate is a good choice.

  • Set up the Video Framerate option higher than source stream is not meaningful, it won't makes the picture looks more fluent, also will cause picture quality bad.

  • If the video pixel format in the source stream is not yuv420p and GPU is not able to encoding it, set up the Video Pixel Format option to yuv420p will solve the issue.

# Audio Encoding

You can go to the Stream Settings page and set up the Audio Encoders's codec option to aac, mp3 or mp2 for enable the audio transcoding.

  • Audio Channels Only mono and stereo channels are supported.

  • Audio Sample Rate Recommend use 44100 for most of cases.

  • Audio Volume This option is for adjust the audio volume.

TIP

Since audio transcoding doesn't use too much CPU, so there is no hardware acceleration for audio transcoding. The libfdk_aac encoder is same like native aac, but it will product better audio quality with more CPU cost. For best performance, use native aac is okay.

# Subtitle Encoding

The panel will copy the subtitle tracks from input to the output in default. If you need hard code the DVB subtitle or teletext to the video, you can go to the Stream Settings page and set up the Subtitle Encoder option to overlay. Also you may need set up the Subtitle Map option properly, because we can hard code one subtitle into the video only.

# Overlay Image

You can use the Overlay Image option for overlay the static or dynamic logo or watermark to the video. You can click the upload icon at right of this option to upload the logo image or video. Or select it if you uploaded already.

  • X The most left location of logo.
  • Y The most top location of logo.
  • opacity The logo opacity, 0 means fully transparent, 1 means fully not transparent, it's 1 in default.

TIP

You need use avi, flv, mkv, mp4, mpg, mpeg, ts, mov, rmvb or webm format for dynamic logo or watermark. Here is some examples for X and Y values:

X Y location
50 50 top left corner
W-w-50 50 top right corner
50 H-h-50 bottom left corner
W-w-50 H-h-50 bottom right corner

W and H is the width and height of input video, w and h is the width and height of logo or watermark. If your logo is not plan to add to top left corner, we recommend you use W, H, w, h characters to specify the logo location, instead of use absolute X and Y value, because if X and Y value overflow you will not see the logo or watermark.

# Overlay Text

You can use Overlay Text option for overlay the custom text to the video, and click the icon at right of Overlay Text option will show you more options.

  • text The text you want to overlay, and you can use %{localtime\:%T} or %{gmtime\:%T} in this option for print the local or UTC time.
  • x The most left location of logo.
  • y The most top location of logo.
  • fontsize The number for specify the font size.
  • fontcolor The font color can be specified in name format, like: black, white, blue, darkblue. or in hex color code 0xaabbcc or #aabbcc format for any color.
  • opacity The logo opacity, 0 means fully transparent, 1 means fully not transparent, it's 1 in default.

TIP

X Y location
50 50 top left corner
W-tw-50 50 top right corner
50 H-th-50 bottom left corner
W-tw-50 H-th-50 bottom right corner

W and H is the width and height of input video, tw and th is the width and height of text.

You can use the Video Delogo option to blur a specified rectangle area in the video, it requires you to specify both x, y, width and height options for enable it. It's better to take a snapshot in VLC for your source, and use some tools like PS or GIMP to check the logo's location info.

  • x The most left location of logo.
  • y The most top location of logo.
  • width The width of logo.
  • height The height of logo.

This option is using the computer vision to detect and blur the dynamic logo or watermark. Since it's computer vision, you can not assume it will working 100% all the time. But if your logo or watermark is very clear, and source stream has very good quality. It should able to detect and blur it very stable.

You need prepare a sample logo or watermark image before use this option. After you sample image is ready, you can click the icon at right of Computer Vision Delogo option to upload and select it. And click the icon will show you more options:

  • device Specify use CPU or GPU to do the computer vision delogo, this option is added in 4.7.17 version.
  • buffer queue size We are using a internal buffer for cache the video frames, if there is one frame has logo or watermark detected, it will blur some previous frames for make sure the logo or watermark is removed completely. Lower value will decrease the memory usage and the latency, but may cause the logo or watermark partial removed.
  • detect interval Since detect the logo or watermark will use lot of CPU, so this option will detect the frames with a specified interval, and save the CPU. recommend 1~8.
  • score min The panel will search the entire video frame for the target logo or watermark, and give it a score. This option will filter the wrong detect, so use the default value is okay.
  • scale min, scale max You can use this option if the target logo or watermark may change it's size.
  • left, right, top, bottom This option is for specify the extra pixels to blurred.

Prepare Sample Logo Image

  • You have to use VLC to watch the source stream, and use VLC's Video > Snapshot option to take the snapshot when the logo or watermark show clearly on the screen. Make sure the logo has a plain color background is also important.
  • Install the GIMP from https://www.gimp.org/ (opens new window). You can skip this step if you have GIMP installed already.
  • Open the snapshot image in GIMP. Click Tools > Selection Tools > Rectangle Select and select the logo or watermark only. Then click Image > Crop to Selection. And click File > Export As to save the cropped image in jpg or png format. And this is the sample image we needed.
  • Go to the Stream Settings page in the X Acceleration Codec panel, and click the upload icon at right of Computer Vision Delogo option, for upload the sample image and select it.

# Advanced

# Stream Mapping

You can use Video Map, Audio Map and Subtitle Map option to control the which video, audio or subtitle tracks need map to the output. Here is some examples:

  • v:best means select the best quality video track.
  • v:1920x1080 or v:1080p means select the 1080p video track. If source has multiple 1080p tracks, it will select the best one.
  • v:0 means select the first video track.
  • a:0 means select the first audio track.
  • s:0 means select the first subtitle track.
  • s:0? means select the first subtitle track, the ? mark means don't raise error if it's not exists.
  • i:0x100 means select the PID 0x100 track.
  • m:language:eng means select the english language track.
  • v means select all video tracks.
  • a means select all audio tracks.
  • a:0, a:1 means select the first and second audio tracks.

TIP

Please ensure the map option you filled is correct, incorrect or non exists map will cause the stream not able to start. And it will show you the errors in the panel log.

# Audio/Video Sync

If the stream has audio out of sync issue after stream running for some hours, I recommend you upgrade the panel to the latest first, because old version may fixed some bugs that caused audio out of sync, and check this guide link for how to upgrade. Then you can try set up the Video Sync Method to Pass Through and Video Framerate to Auto.

# Decrease Latency

Normally, the panel will has 30 seconds latency after restream or transcoding, if you want to decrease the latency, you can try following steps:

  • Change the source stream and output to use low latency protocols, for example: HTTP-TS, RTMP, UDP, RTP, SRT.
  • Set up the Format Flags option to use nobuffer flag.
  • Set up the Keyframe Interval option to the 2 times of output framerate if you are transcoding the stream.

# PID Mapping

You can go to the Stream Settings page, and use Pid Map option to remap the MPEG-TS PID for output streams. The syntax is: 0:0xPID, 1:0xPID, 2:0xPID. 0, 1, 2 is the output stream ID, and 0xPID is the new PID you want to assigned.

# Service Info

The panel use the service ID, service name and service provider info that available in the source stream for HLS output. And use the stream name for service name if service name is not available in the source stream. Also, you can use the Service ID, Service Name and Service Provider options in the Stream Settings page for manually specify the service info.

# Scheduled Restart

If you need restart the stream at specified time, you can go to the Stream Settings page and set up the Restart Schedule option.

Also, we have another Stream Restart Schedule option in Settings > System Settings page for scheduled restart all the stream. And you can use the Stream Start/Restart Interval option to control the interval between start/restart each stream.

# Timeshift

If you want to time shift the stream to another timezone or delay the live stream. You can go to the Stream Settings page and set up the Timeshift option. It will cache the stream in the /opt/xaccel-codec/timeshift directory, so it's important to make sure you have enough free space if you need timeshift the stream for many hours.

# Stream Sleep

We have Stream Sleep option in the Stream Settings page for sleep the stream at the specified time of every day. For example: if you fill 8:00-20:00, the stream will sleep from 8 AM to 8 PM. Also, you can specify multiple sleep time like this: 8:00-11:00, 13:00-17:00.

# Stream On Demand

We are supports to set up the stream to streaming only when there are clients are playing it. You can set up the Stream On Demand option to Yes in the Stream Settings page for enable it.

Notice

There is a latency between the first client connecting and streaming ready. For decrease the latency, you can use the HLS or HTTP-TS source with a large buffer size.

# Stream Monitoring

We have the feature for monitoring the stream's system and graphics memory usage and speed in realtime. And force restart the stream if the usage is unusual or speed too fast or slow. You can use following options for set up the max memory usage or speed range you allowed.

  • Memory Limit It will automatically calculate the max system and graphics memory the channel may use. You can override it in this option, If source stream has too many bad packets or DVB signal or quality is not good in this case, we recommend you check source instead of set a large value for this option. It may affect the system stability.
  • Speed Limit For live stream, the speed should always stable on 1x. It's normal that it faster than 1x at beginning of stream running. Also, 0.99x or 1.01x is okay too. The panel is using 0.5 and 1.5 for min and max speed in default.

Speed Slow Reason

  • The internet between source and X Acceleration Codec server has reached the max bandwidth. You can run following command on both server to measure the bandwidth: wget -O - https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python
  • The GPU is overloaded. you will see all other streams running on the same GPU will has slow speed issue too.

# Outputs

# Multiple Bitrate Outputs

We supports encoding the stream to multiple bitrate and output to multiple protocols.

First, go to the Stream settings page, click the icon at right of Video Encoders, Audio Encoders option for add multiple codec and bitrate. Then scroll to the output section in the bottom page, select the video and audio bitrate you just added in the output's Video Encoders, Audio Encoders option.

# HLS ABR

The HLS ABR is same set up steps as above Multiple Bitrate Outputs, the only difference you need add an additional HLS Master output, for select the multiple bitrate HLS outputs you created in the Variants option.