Project

General

Profile

Actions

Custom MPEG-TS Input » History » Revision 22

« Previous | Revision 22/28 (diff) | Next »
dhead 666, 2015-03-09 18:52
add a note about -tune zerolatency


Custom MPEG-TS Input

Requirement

The TVHeadend 3.9.2100 and up for the pipe:// URL support. Note that TVHeadend expects the input in the raw MPEG-TS format with correct PAT/PMT tables.

IPTV URLs

Note: Always try the command without pipe:// prefix on standard command line, if it works with a stdout redirection to a file!!

Streaming from a file

Use option -re for the input specification to stream the file at native frame rate.

  -re (input)

      Read input at native frame rate. Mainly used to simulate a grab
      device.  or live input stream (e.g. when reading from a file).
      Should not be used with actual grab devices or live input streams
      (where it can cause packet loss).  By default ffmpeg attempts to
      read the input(s) as fast as possible.  This option will slow down
      the reading of the input(s) to the native frame rate of the
      input(s). It is useful for real-time output (e.g. live streaming).

Internet Radios

Note: FFmpeg flag '-tune zerolatency' depends on the x264 encoder (libx264), remove it if it isn't available on your system (e.g. OpenELEC).

From ffmpeg v2.6 and on one can set the service type of the mpegts stream as radio.

pipe:///usr/bin/ffmpeg -loglevel fatal -i INPUTLINK -vn -acodec copy -metadata service_provider=RADIOPROVIDER
  -metadata service_name=RADIONAME -tune zerolatency -f mpegts -mpegts_service_type digital_radio pipe:1

With older ffmpeg releases the mpegts service type cannot be set correctly so the audio stream will be listed as a TV channel, you can use a static image that will be shown with the audio stream (the Radio Logo maybe?).

pipe:///usr/bin/ffmpeg -loglevel fatal -loop 1 -y -i /path/to/image.png -re -i INPUTLINK
  -vcodec libx264 -acodec copy -mbd rd -copyinkf -flags +ilme+ildct -fflags +genpts
  -metadata service_provider=RADIOPROVIDER -metadata service_name=RADIONAME -tune zerolatency -f mpegts pipe:1

Transcoding

YMMV with different ffmpeg/libav versions. In Red Hat's (Fedora/Centos) build of ffmpeg, aac transcoding is experimental, so you have to enable -strict -2

pipe:///usr/bin/ffmpeg -loglevel fatal -i INPUTLINK -vcodec libx264 -acodec aac -strict -2 -mbd rd -copyinkf -flags +ilme+ildct -fflags +genpts
  -metadata service_provider=STRING -metadata service_name=STRING -f mpegts -tune zerolatency pipe:1

Try to transcode as little as possible, since it will impact your cpu usage. And if you're using tvheadend to re-transcode... well..

So if your channel already has aac audio, maybe you only need to transcode the video stream.

pipe:///usr/bin/ffmpeg -loglevel fatal -i INPUTLINK -vcodec libx264 -acodec copy -mbd rd -copyinkf -flags +ilme+ildct -fflags +genpts
  -metadata service_provider=STRING -metadata service_name=STRING -f mpegts -tune zerolatency pipe:1

Direct copy (container only change)

pipe:///usr/bin/ffmpeg -loglevel fatal -i INPUTLINK -vcodec copy -acodec copy -metadata service_provider=STRING
  -metadata service_name=STRING -f mpegts -tune zerolatency pipe:1

Cookie-protected HLS Streams
ffmpeg is not the smartest cookie in the jar handling cookies (pun intended). So while you can insert cookies using the -cookie option, and alternative option is using Squid with request_add_header option

request_header_add Cookie 'YOUR COOKIE CONTENT' all

The trailing all refers to the ACL it applies to. Please read the full documentation on how to implement this on the Squid Website (http://www.squid-cache.org/Doc/config/request_header_add/)

Other solutions (HTTP proxy)

A simple ffmpeg HTTP proxy using nodejs

Updated by dhead 666 almost 10 years ago · 22 revisions