Enable live tv streaming from tvheadend
Added by Henry Goodman over 5 years ago
I am new to ffmpeg and tvheadend. However, I would like to create a live TV stream using tvheadend or a combination of ffmpeg and tvheadend.
From tvheadend, I can view the different tv channels - however, they stop working after a while i.e. 10-30 minutes. The stream profiles I use is webtv-h264-aac-matroska. webtv-h264-aac-matroska allows me to view a channel on chrome by setting the type to web/mp4 on the native html5 video tag. From the tvheadend logs, I also noticed the warning [WARNING]:libav: forced frame type (5) at 2159 was changed to frame type (3). I wonder whether this could be causing the stop after some time.
As a result, I resorted to using ffmpeg and generate a hls stream using the module nginx-ts-module. This only works on tvheadend when I use the profile webtv-h264-aac-mpegts as the input stream. However, the video generation process is slow and the video gets blocky. At times the audio doesn't work and the video also freezes. The command I use is ffmpeg -loglevel verbose -i http://localhost:9981/stream/channel/13823d4167df6e44f1a0b7cbf88829a5?profile=webtv-h264-aac-mpegts -c:v copy -c:a copy -f mpegts http://127.0.0.1:8000/publish/sintel. If I use the link http://localhost:9981/stream/channel/13823d4167df6e44f1a0b7cbf88829a5?profile=webtv-h264-aac-mpegts on vlc, the output is still blocky and hangs sometimes. However, if I just use http://localhost:9981/stream/channel/13823d4167df6e44f1a0b7cbf88829a5 i.e. without the profile, vlc audio is perfect, though output is sometimes blocky.
Any help?
I just need a way to view the live stream on a browser - whether it comes from tvheadend only or a combination of tvheadend and ffmpeg.
Replies (3)
RE: Enable live tv streaming from tvheadend - Added by saen acro over 5 years ago
get channels link from
http://tvh.ip.or.dns:9981/playlist/channels
It is recommended to use GPU to transcode
RE: Enable live tv streaming from tvheadend - Added by Henry Goodman over 5 years ago
Thanks Saen Acro for the prompt reply.
I used the channel list from http://tvh.ip.or.dns:9981/playlist/channels as you indicated and the output I am getting is contained in the attached file. The output includes some warnings and errors. Further, I now can't see any output on the browser. It seems like it's loading indefinitely.
The command I used is ffmpeg -loglevel verbose -i "http://localhost:9981/stream/channelid/1839535927?ticket=A52D15594B4B0B9DFC77FFE75D14FE31A06C0A35&profile=pass" -c:v copy -c:a copy -crf 23 -maxrate 1M -bufsize 2M -f mpegts http://127.0.0.1:8000/publish/sintel
output.txt (17.9 KB) output.txt |
RE: Enable live tv streaming from tvheadend - Added by saen acro over 5 years ago
remove ticked part
http://localhost:9981/stream/channelid/1839535927?ticket=A52D15594B4B0B9DFC77FFE75D14FE31A06C0A35&profile=pass
to
http://localhost:9981/stream/channelid/1839535927?&profile=pass
pass can be changed to any other in TVH
try this with nvidia
ffmpeg -fflags +genpts -nostats -nostdin -hide_banner -loglevel quiet -hwaccel cuvid -c:v h264_cuvid -deint 1 -surfaces 8 -drop_second_field 1 -vsync 0 -resize 1280x720 -i -map 0:v -c:v h264_nvenc -preset slow -profile:v high -level 4.1 -rc vbr -cq 1 -bf 2 -g 25 -b:v 2200k -minrate 2200k -maxrate 2200k -bufsize 1002k -map 0:a -c:a libfdk_aac -ac 2 -b:a 128k -strict experimental
or by cpu post processing transcode
ffmpeg -i %f -b 1550k -bt 1792k -vcodec libx264 -pass 1 -vpre fastfirstpass -an -threads 2 %b.mp4 && ffmpeg -y -i %f -b 1550k -bt 1792k -vcodec libx264 -pass 2 -vpre hq -acodec libfaac -threads 2 %b.mp4