Thanks @Em Smith for your review of this issue. 
> Only other thing you haven't mentioned is amount of swap space/swap used, though I'd expect some out of memory (OOM) messages to be logged if you had a memory leak using all your memory.
The machine has 4 GB RAM and also 3.7 GB swap, but I think swap is never used. In fact, I checked free mem and there is always available
> If you don't use vaapi does your machine lock up? 
I created a stream profile to transcode using libx264 without hw acceleration, it´s continuously buffering (top reports 140% CPU usage) but the machine didn't freezes. It seems to freeze only using VAAPI.
> Have you tried running "ffmpeg" with "vaapi" outside tvheadend (at a console) to convert a large recording and determine if vaapi is causing the problem. You could run it in a loop overnight and see if your machine survives.
Could you please confirm what would be the command to run ffmpeg with vaapi using a H264 stream as input, or where I can find a guide for this? 
> Is your machine completely locked up so not even the keyboard works?
Yes, correct. Nothing works, the console is totally black and keyboard is not working. After the freeze I need to power off the machine, then when it comes up I tried to find any crash info or log, but I am not able to find anything.. perhaps I am not searching correctly.. 
> I'd run a "top" in another virtual console and leave that console as the active one, so when the machine dies you can see what was running at the time and amount of cpu/memory used.
This is the output of the top at the moment of a freeze:
top - 20:12:55 up 22:13,  1 user,  load average: 0.42, 0.50, 0.60
Tasks: 140 total,   1 running,  83 sleeping,   0 stopped,   0 zombie
%Cpu(s):  5.6 us,  4.7 sy,  0.0 ni, 83.3 id,  6.1 wa,  0.0 hi,  0.3 si,  0.0 st
KiB Mem :  3738940 total,   783892 free,   594664 used,  2360384 buff/cache
KiB Swap:  3738620 total,  3738620 free,        0 used.  1989736 avail Mem
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
  691 hts       20   0 3509524 226992  34728 S  33.1  6.1  61:10.91 tvheadend
19489 root      20   0       0      0      0 I   6.3  0.0   0:06.50 kworker/1:2
    3 root      20   0       0      0      0 I   1.7  0.0   0:46.66 kworker/0:0
 1292 asterisk  20   0 2666736  46392  24744 S   0.7  1.2  11:11.80 asterisk
17766 root      20   0   42800   4104   3456 R   0.7  0.1   0:19.23 top
    8 root      20   0       0      0      0 I   0.3  0.0   0:33.11 rcu_sched
    1 root      20   0  225172   9092   6892 S   0.0  0.2   0:08.65 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.08 kthreadd
As you can see CPU usage is low, in this case I was running a single stream with transcoding (H264 1080i -> H264 720p with 2000 bitrate). It also reports 783K memory free. I will run powertop this night.
Thanks!
<<