Hacktv: analogue tv transmitter

Captain Jack

Burnt out human
Joined
Oct 21, 2006
Messages
11,797
Reaction score
7,980
Points
113
My Satellite Setup
See signature
My Location
North Somerset
Thought I'd start a separate thread on HackTV and any updates to go here, rather than all over the place.

Some threads that started HackTV's various features:


What is it?

As the thread title suggests, it's an analogue TV transmitter made, primarily, for HackRF SDR. Other SDRs, such as Pluto, BladeRF and LimeSDR are supported but your mileage may vary. It also supports fl2k device for baseband output. Works best on Linux based OSs or Mac, though there is a script to compile it for Windows. @steeviebops is your man for this!

Main features:
  • Pretty much all analogue systems are supported, from Baird 30 line to MAC, to SECAM 819, to Apollo TV.
  • A variety for scrambling systems used for PAL, SECAM and D/D2MAC.
  • Modulation in FM, VSB/AM and baseband, so will be good for either your old satellite receiver or directly into your TV.
  • Stereo NICAM audio.
  • Teletext.
  • Subtitling
  • Can stream from pretty much anything - either a file or a web stream accepted by ffmpeg or a utility such as youtube-dl for direct streaming from YouTube. Who thought you'd could transmit YT in analogue, eh?
  • Scrambling:
    • Videocrypt I
      • Needs any active Sky card between series 6 and 12 or in free-access mode, not requiring a card.
      • Dead Sky 07 and 09 cards can be activated with HackTV.
    • Videocrypt II
      • Needs an active Multichoice card. Or a programmed PIC card.
    • Syster/Nagravision
      • Supports most 'keys' (cards shaped like keys) used in Europe. Or a programmed PIC card.
    • Discret 11
      • Uses "audience 7"/free-view mode. Works with real Discret decoders and Syster ones with a valid key as above.
    • Eurocrypt M
      • Works with official active FilmNet, TV Plus Holland, Viasat (TV1000) or "Multimac" cards.
      • Supports single and double cut mode (scrambling of chroma only or chroma and luma).
Versions:

There are two main versions of HackTV. One is the official release by @fsphil, who's done the vast majority of the work and one that has less bugs :). The other one has been somewhat extended by yours truly to mainly cater for conditional access systems and some other features that may not really warrant inclusion in the main release. Check README files in each repo.

There's a GUI front-end for Windows version of HackTV by @steeviebops if you prefer to click buttons instead of typing stuff out :)
 
Last edited:

Captain Jack

Burnt out human
Joined
Oct 21, 2006
Messages
11,797
Reaction score
7,980
Points
113
My Satellite Setup
See signature
My Location
North Somerset
New update in official repo with fixes for D/D2MAC timings and scrambling.

Added double-cut scrambling in fork.
 

steeviebops

Member
Joined
Nov 19, 2019
Messages
105
Reaction score
74
Points
28
My Satellite Setup
A basic 28.2 Freesat config, but have had a long history of satellite TV dating back to the analogue 19.2 days. Using a HP ZBook 15 G5 laptop (Core i7-8850H, 32GB RAM, Quadro video card)
My Location
Drogheda, Ireland
Thanks for the mention! :) I've uploaded Windows binaries of today's new updates to the OneDrive.

Had some issues compiling your fork though (in both Ubuntu and for Windows). Looks like some of the syntax is platform-specific - I assume you're building this on MacOS as it appears to be BSD syntax?

I can get it to compile by replacing the ‘uint32_t' command with the command suggested by the error. It returns some warnings but compiles and appears to work OK.

Linux errors and warnings:
Code:
font.c: In function ‘get_line_width’:
font.c:270:9: warning: variable ‘l’ set but not used [-Wunused-but-set-variable]
  270 |  int i, l;
      |         ^
gcc -g -Wall -Wno-unused-result -pthread -O3  -I/usr/include/x86_64-linux-gnu -I/usr/include/ -I/usr/include/libusb-1.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/freetype2 -I/usr/include/libpng16 -c subtitles.c -o subtitles.o
subtitles.c: In function ‘parse_time’:
subtitles.c:125:19: warning: ‘t’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  125 |   if(c == ti && t != i)
      |                 ~~^~~~
gcc -g -Wall -Wno-unused-result -pthread -O3  -I/usr/include/x86_64-linux-gnu -I/usr/include/ -I/usr/include/libusb-1.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/freetype2 -I/usr/include/libpng16 -c bitmap.c -o bitmap.o
In file included from bitmap.c:18:
bitmap.h:23:27: error: unknown type name ‘uint32_t’; did you mean ‘u_int32_t’?
   23 | extern void resize_bitmap(uint32_t *input, uint32_t *output, int old_width, int old_height, int new_width, int new_height);
      |                           ^~~~~~~~
      |                           u_int32_t
bitmap.h:23:44: error: unknown type name ‘uint32_t’; did you mean ‘u_int32_t’?
   23 | extern void resize_bitmap(uint32_t *input, uint32_t *output, int old_width, int old_height, int new_width, int new_height);
      |                                            ^~~~~~~~
      |                                            u_int32_t
bitmap.c:23:20: error: unknown type name ‘uint32_t’; did you mean ‘u_int32_t’?
   23 | void resize_bitmap(uint32_t *input, uint32_t *output, int old_width, int old_height, int new_width, int new_height)
      |                    ^~~~~~~~
      |                    u_int32_t
bitmap.c:23:37: error: unknown type name ‘uint32_t’; did you mean ‘u_int32_t’?
   23 | void resize_bitmap(uint32_t *input, uint32_t *output, int old_width, int old_height, int new_width, int new_height)
      |                                     ^~~~~~~~
      |                                     u_int32_t
make: *** [Makefile:32: bitmap.o] Error 1

Windows errors:
Code:
In file included from bitmap.c:18:
bitmap.h:23:27: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
   23 | extern void resize_bitmap(uint32_t *input, uint32_t *output, int old_width, int old_height, int new_width, int new_height);
      |                           ^~~~~~~~
      |                           wint_t
bitmap.h:23:44: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
   23 | extern void resize_bitmap(uint32_t *input, uint32_t *output, int old_width, int old_height, int new_width, int new_height);
      |                                            ^~~~~~~~
      |                                            wint_t
bitmap.c:23:20: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
   23 | void resize_bitmap(uint32_t *input, uint32_t *output, int old_width, int old_height, int new_width, int new_height)
      |                    ^~~~~~~~
      |                    wint_t
bitmap.c:23:37: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
   23 | void resize_bitmap(uint32_t *input, uint32_t *output, int old_width, int old_height, int new_width, int new_height)
      |                                     ^~~~~~~~
      |                                     wint_t
make: *** [Makefile:32: bitmap.o] Error 1
make: *** Waiting for unfinished jobs....
eurocrypt.c: In function '_permute_f':
eurocrypt.c:285:28: warning: array subscript has type 'char' [-Wchar-subscripts]
  285 |   s |= (unsigned long)SB[i][v] << (28 - 4 * i);
 
Last edited:

fsphil

Member
Joined
Apr 27, 2017
Messages
112
Reaction score
52
Points
28
My Satellite Setup
Still playing with analogue. Also running a Humax FOXSAT-HDR and a Thomson THS804.
My Location
UK
uint32_t is defined in stdint.h, make sure that's included at the top
 

Captain Jack

Burnt out human
Joined
Oct 21, 2006
Messages
11,797
Reaction score
7,980
Points
113
My Satellite Setup
See signature
My Location
North Somerset
Thanks both. Strangely, I do not get those errors on my Mac.

Give the new push a go.
 

steeviebops

Member
Joined
Nov 19, 2019
Messages
105
Reaction score
74
Points
28
My Satellite Setup
A basic 28.2 Freesat config, but have had a long history of satellite TV dating back to the analogue 19.2 days. Using a HP ZBook 15 G5 laptop (Core i7-8850H, 32GB RAM, Quadro video card)
My Location
Drogheda, Ireland
Thanks both. Strangely, I do not get those errors on my Mac.

Give the new push a go.
Excellent, works fine now for both Linux and Windows. For Windows I use my custom build script and need to edit hacktv.c and ffmpeg.c to change the directory separators.
 

Captain Jack

Burnt out human
Joined
Oct 21, 2006
Messages
11,797
Reaction score
7,980
Points
113
My Satellite Setup
See signature
My Location
North Somerset
OK good. Which directory separators do you need to change?
 

steeviebops

Member
Joined
Nov 19, 2019
Messages
105
Reaction score
74
Points
28
My Satellite Setup
A basic 28.2 Freesat config, but have had a long history of satellite TV dating back to the analogue 19.2 days. Using a HP ZBook 15 G5 laptop (Core i7-8850H, 32GB RAM, Quadro video card)
My Location
Drogheda, Ireland
I noticed the following in hacktv.c and ffmpeg.c:

Code:
#ifdef WIN32
#define OS_SEP '\\'
#else
#define OS_SEP '/'
#endif

and
Code:
asprintf(&vid_conf.logo,"resources%clogos%c%s", OS_SEP, OS_SEP, s.logo);

Correct me if I'm wrong but this looks like "if Win32, define the variable as "\" otherwise it is "/". If I leave this as-is and compile, --logo can't find the PNG files. If I change it back to / then it works fine. So you can remove the variable altogether.
 

Captain Jack

Burnt out human
Joined
Oct 21, 2006
Messages
11,797
Reaction score
7,980
Points
113
My Satellite Setup
See signature
My Location
North Somerset
Strange. Perhaps the compiler knows what path separators to use without this.
 

steeviebops

Member
Joined
Nov 19, 2019
Messages
105
Reaction score
74
Points
28
My Satellite Setup
A basic 28.2 Freesat config, but have had a long history of satellite TV dating back to the analogue 19.2 days. Using a HP ZBook 15 G5 laptop (Core i7-8850H, 32GB RAM, Quadro video card)
My Location
Drogheda, Ireland
What’s the syntax for the subtitle parameter? Is it just the index number of the subtitles in the video file? I’m looking at implementing it in the GUI but will need to make some changes to the layout to accommodate it.
 

Captain Jack

Burnt out human
Joined
Oct 21, 2006
Messages
11,797
Reaction score
7,980
Points
113
My Satellite Setup
See signature
My Location
North Somerset
It's just an index to subtitle stream - an integer. Usually 2 or 3 but depends on the number of audio tracks present. By default, it picks the first available one and the parameter is optional, so I'd just put a check box rather than a selection. In case of external subtitles (srt files), the parameter is ignored anyway.

The whole thing is experimental and @fsphil will probably release something more stable (bits of code are all over the place here).
 

steeviebops

Member
Joined
Nov 19, 2019
Messages
105
Reaction score
74
Points
28
My Satellite Setup
A basic 28.2 Freesat config, but have had a long history of satellite TV dating back to the analogue 19.2 days. Using a HP ZBook 15 G5 laptop (Core i7-8850H, 32GB RAM, Quadro video card)
My Location
Drogheda, Ireland
Out of interest, what sort of hardware are you all using for this? My laptop struggles with the filter command on AM modes (but not on FM).


My laptop would have been a beast in its day but that was 2013! I've started playing with GNU Radio recently and found it has the same issue with FM RDS graphs. To rule out any possible Windows issue, I also ran it on Ubuntu (not in a VM by the way) but the result was the same.
 

Captain Jack

Burnt out human
Joined
Oct 21, 2006
Messages
11,797
Reaction score
7,980
Points
113
My Satellite Setup
See signature
My Location
North Somerset
I am using a 2015 iMac - Skylake i5 processor.

--filter in AM mode is flaky for me. @fsphil suggested changing the number of taps used for it. Line 2051 in original code.

I find that the max on my machine is around 35 taps but does underflow now and again. I settled on 25.

Maybe make it an optional parameter?
 

steeviebops

Member
Joined
Nov 19, 2019
Messages
105
Reaction score
74
Points
28
My Satellite Setup
A basic 28.2 Freesat config, but have had a long history of satellite TV dating back to the analogue 19.2 days. Using a HP ZBook 15 G5 laptop (Core i7-8850H, 32GB RAM, Quadro video card)
My Location
Drogheda, Ireland
Thanks. I probably should have said that I’m on an Ivy Bridge i7 so it is fairly old now. I’ve been considering replacing it with something newer but would want to be sure it’ll do what I‘d like.
 

fsphil

Member
Joined
Apr 27, 2017
Messages
112
Reaction score
52
Points
28
My Satellite Setup
Still playing with analogue. Also running a Humax FOXSAT-HDR and a Thomson THS804.
My Location
UK
There is still some room for improvement in how the filter works. Currently my laptop (Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz) struggles, but my desktop (Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz) handles it fine in most cases.
 

steeviebops

Member
Joined
Nov 19, 2019
Messages
105
Reaction score
74
Points
28
My Satellite Setup
A basic 28.2 Freesat config, but have had a long history of satellite TV dating back to the analogue 19.2 days. Using a HP ZBook 15 G5 laptop (Core i7-8850H, 32GB RAM, Quadro video card)
My Location
Drogheda, Ireland
Well I picked up another beast yesterday. A HP ZBook 15 G5 with a Core i7-8850H. Runs anything I throw at it, including the filter!
 

Captain Jack

Burnt out human
Joined
Oct 21, 2006
Messages
11,797
Reaction score
7,980
Points
113
My Satellite Setup
See signature
My Location
North Somerset

steeviebops

Member
Joined
Nov 19, 2019
Messages
105
Reaction score
74
Points
28
My Satellite Setup
A basic 28.2 Freesat config, but have had a long history of satellite TV dating back to the analogue 19.2 days. Using a HP ZBook 15 G5 laptop (Core i7-8850H, 32GB RAM, Quadro video card)
My Location
Drogheda, Ireland
I thought I'd post an update regarding the section of mac.c that has been causing issues on Windows. I normally worked around it by removing the section in question but I decided to put a couple of hours into trying to fix it altogether. I had to change three parts to get it to work; seems Windows expects localtime_s and gmtime_s rather than localtime_r and gmtime_r. They accept the same data but with the parameters reversed. Additionally, I replaced tm.tm_gmtoff with _timezone. I'm not 100% that it works as I don't really know what the code does, but I get no compilation errors at all now so it looks promising.

Anyway, here is the change I make to mac.c before compiling:

C:
#ifndef WIN32
    /* Get the timezone offset */
    localtime_r(&timestamp, &tm);
    i = tm.tm_gmtoff / 1800;
    if(i < 0) i = -i | (1 << 5);
    
    /* Calculate Modified Julian Date */
    gmtime_r(&timestamp, &tm);
    mjd = 367.0 * (1900 + tm.tm_year)
        - (int) (7.0 * (1900 + tm.tm_year + (int) ((1 + tm.tm_mon + 9.0) / 12.0)) / 4.0)
        + (int) (275.0 * (1 + tm.tm_mon) / 9.0) + tm.tm_mday - 678987.0;
#else
    /* Get the timezone offset */
        localtime_s(&tm, &timestamp);
        i = _timezone / 1800;
        if(i < 0) i = -i | (1 << 5);
    
    /* Calculate Modified Julian Date */
        gmtime_s(&tm, &timestamp);
        mjd = 367.0 * (1900 + tm.tm_year)
            - (int) (7.0 * (1900 + tm.tm_year + (int) ((1 + tm.tm_mon + 9.0) / 12.0)) / 4.0)
            + (int) (275.0 * (1 + tm.tm_mon) / 9.0) + tm.tm_mday - 678987.0;
#endif
 

fsphil

Member
Joined
Apr 27, 2017
Messages
112
Reaction score
52
Points
28
My Satellite Setup
Still playing with analogue. Also running a Humax FOXSAT-HDR and a Thomson THS804.
My Location
UK
I'm torn between fixing this properly or just removing it entirely - or at least commenting it out. Myself and @Captain Jack have yet to find a decoder that uses the time data on line 625.
 

steeviebops

Member
Joined
Nov 19, 2019
Messages
105
Reaction score
74
Points
28
My Satellite Setup
A basic 28.2 Freesat config, but have had a long history of satellite TV dating back to the analogue 19.2 days. Using a HP ZBook 15 G5 laptop (Core i7-8850H, 32GB RAM, Quadro video card)
My Location
Drogheda, Ireland
Does anyone here use SDRs other than the HackRF with hacktv? The reason I ask is that I'm looking to implement support for other SDRs to my GUI but am not entirely sure of the syntax. I'd like to implement as many of the options as possible.

- I have an FL2000-based VGA adapter in the post (€10 on eBay so no big deal) so hope to test this soon. I'll need to add the baseband (real) modes for this one too. Am I right in saying that it doesn't support RF modulation so I should disable all of the frequency and channel options when it's selected?

- For SoapySDR, I see the parameters mention --output soapysdr[:<opts>]; what sort of options would these be? Would I provide a text field for this or is it more specific than that?
 
Top