Custom MPEG-TS Input » History » Version 12
Jaroslav Kysela, 2014-11-18 12:10
1 | 1 | Jaroslav Kysela | h1. Custom MPEG-TS Input |
---|---|---|---|
2 | |||
3 | h2. Requirement |
||
4 | |||
5 | 2 | Jaroslav Kysela | 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. |
6 | 1 | Jaroslav Kysela | |
7 | h2. IPTV URLs |
||
8 | |||
9 | 5 | Jaroslav Kysela | Note: Always try the command without pipe:// prefix on standard command line, if it works with a stdout redirection to a file!! |
10 | |||
11 | 11 | Jaroslav Kysela | h3. Streaming from a file |
12 | |||
13 | Use option -re for the input file to en |
||
14 | |||
15 | <pre> |
||
16 | -re (input) |
||
17 | |||
18 | Read input at native frame rate. Mainly used to simulate a grab |
||
19 | device. or live input stream (e.g. when reading from a file). |
||
20 | Should not be used with actual grab devices or live input streams |
||
21 | (where it can cause packet loss). By default ffmpeg attempts to |
||
22 | read the input(s) as fast as possible. This option will slow down |
||
23 | the reading of the input(s) to the native frame rate of the |
||
24 | input(s). It is useful for real-time output (e.g. live streaming). |
||
25 | </pre> |
||
26 | |||
27 | 10 | Nicolas C | h3. Internet Radios |
28 | 1 | Jaroslav Kysela | |
29 | 10 | Nicolas C | Unfortunately ffmpeg can't set the right header for Radios, so they'll show up as TV Channels :(. So while its not ideal, you can show a static image (the Radio Logo maybe?) |
30 | |||
31 | 1 | Jaroslav Kysela | <pre> |
32 | 11 | Jaroslav Kysela | pipe:///usr/bin/ffmpeg -loglevel fatal -loop 1 -y -i /path/to/image.png -re -i INPUTLINK |
33 | -vcodec libx264 -acodec copy -mbd rd -copyinkf -flags +ilme+ildct -fflags +genpts |
||
34 | -metadata service_provider=RADIOPROVIDER -metadata service_name=RADIONAME -tune zerolatency -f mpegts pipe:1 |
||
35 | 1 | Jaroslav Kysela | </pre> |
36 | 10 | Nicolas C | |
37 | 11 | Jaroslav Kysela | h3. Transcoding |
38 | 10 | Nicolas C | |
39 | 1 | Jaroslav Kysela | 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 |
40 | |||
41 | 10 | Nicolas C | <pre> |
42 | 11 | Jaroslav Kysela | pipe:///usr/bin/ffmpeg -loglevel fatal -i INPUTLINK -vcodec libx264 -acodec aac -strict -2 -copyinkf -flags +ilme+ildct -fflags +genpts |
43 | -metadata service_provider=STRING -metadata service_name=STRING -f mpegts -tune zerolatency pipe:1 |
||
44 | 10 | Nicolas C | </pre> |
45 | |||
46 | Try to transcode as little as possible, since it will impact your cpu usage. And if you're using tvheadend to re-transcode... well.. |
||
47 | |||
48 | So if your channel already has aac audio, maybe you only need to transcode the video stream. |
||
49 | |||
50 | <pre> |
||
51 | 12 | Jaroslav Kysela | pipe:///usr/bin/ffmpeg -loglevel fatal -i INPUTLINK -vcodec libx264 -acodec copy -copyinkf -flags +ilme+ildct -fflags +genpts |
52 | 6 | Jaroslav Kysela | -metadata service_provider=STRING -metadata service_name=STRING -f mpegts -tune zerolatency pipe:1 |
53 | 7 | Jaroslav Kysela | </pre> |
54 | 6 | Jaroslav Kysela | |
55 | h3. Direct copy |
||
56 | 8 | Jaroslav Kysela | |
57 | 6 | Jaroslav Kysela | <pre> |
58 | 1 | Jaroslav Kysela | pipe:///usr/bin/ffmpeg -loglevel fatal -i INPUTLINK -vcodec copy -acodec copy -metadata service_provider=STRING |
59 | -metadata service_name=STRING -f mpegts -tune zerolatency pipe:1 |
||
60 | </pre> |
||
61 | |||
62 | h2. Other solutions (HTTP proxy) |
||
63 | |||
64 | 10 | Nicolas C | |
65 | 11 | Jaroslav Kysela | "A simple ffmpeg HTTP proxy using nodejs":https://github.com/Jalle19/node-ffmpeg-mpegts-proxy |