So I'm using the great TVHeadend, which is in my case a DVB-T or IPTV server that can record greatly some inputs. This is a great piece of software, which I recommend much.
But I'm a little bit confused in here. So I've set up a tvheadend on a raspberry pi 4, because I need for my work to record a lot of tv programs. I appreciate TVheadend very much on an other installation, and so are my coworkers who also needs to use it and not a CLI only interface (that's relevant you'll see).
So when I'm using a simple ffmpeg command like this :
ffmpeg -err_detect ignore_err -i http://mystream -to 00:10:00 -codec copy /media/partage/dvr/test.mp4
my cpu usage goes to something like 1 or 2% percent. But when I'm trying to replicate that in tvheadend, the cpu goes to 400%, and clearly it's not the same behavior.
Here my stream configuration :
Here's the result with ffmpeg codec copy :
General
Complete name : /Volumes/Share/dvr/test2.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 58.3 MiB
Duration : 3mn 20s
Overall bit rate : 2 436 Kbps
Writing application : Lavf58.20.100
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings : 2 Ref Frames
Format settings, CABAC : No
Format settings, ReFrames : 2 frames
Format settings, GOP : M=3, N=50
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 3mn 20s
Bit rate : 2 300 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.100
Stream size : 55.0 MiB (94%)
Codec configuration box : avcC
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 3mn 20s
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 1 channel
Channel layout : C
Sampling rate : 44.1 KHz
Frame rate : 43.066 fps (1024 SPF)
Compression mode : Lossy
Stream size : 3.07 MiB (5%)
Language : French
Default : Yes
Alternate group : 1
And the result with tvheadend :
General
Complete name : /Volumes/Share/dvr/2020-04-01/BFMTV/Edition-speciale-BFMTV2020-04-0121-00.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/iso6/mp41)
File size : 8.40 MiB
Duration : 42s 486ms
Overall bit rate : 1 659 Kbps
Movie name : Edition spéciale
Writing application : Lavf58.20.100
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 40s 512ms
Bit rate : 11.9 Kbps
Nominal bit rate : 1 500 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Frame rate : 25.000 fps
Minimum frame rate : 13.885 fps
Maximum frame rate : 25.014 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.001
Stream size : 58.6 KiB (1%)
Writing library : x264 core 155 r2917 0a84d98
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=125 / keyint_min=12 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=1500 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=1875 / vbv_bufsize=5625 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Codec configuration box : avcC
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 42s 486ms
Bit rate mode : Constant
Bit rate : 172 bps
Nominal bit rate : 172 Kbps
Channel(s) : 1 channel
Channel layout : C
Sampling rate : 48.0 KHz
Frame rate : 46.875 fps (1024 SPF)
Compression mode : Lossy
Stream size : 915 Bytes (0%)
Language : French
Default : Yes
Alternate group : 1
As you can see, Tvheadend is making a variable bitrate and variable framerate file, which is really bad for Premiere Pro (which is the main goal for all this). Clearly it's transcoding it, which I don't need, in a format that is worst for my workflow.
My Pi4 is on Raspbian Buster, but I've also tried this with the same unfortunate result on libreelec.
Does anyone has any idea ?
I think I found the answer.
So TvHeadend is using pipe:// , which is streaming. So, according to the ffmpeg doc, you can't use mp4 but TS and FLV. So basically I've made a post-record process : ffmpeg -i "%f" -map 0 -c copy /media/partage/dvr/%b And that's doing the job, with 1 or 2% CPU usage.