Skip to content

Instantly share code, notes, and snippets.

@muxlux
Forked from Juul/cheap_1080p_hdmi_capture.md
Created April 1, 2019 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muxlux/ab04f614ef01c3013b7d483b1d5551dd to your computer and use it in GitHub Desktop.
Save muxlux/ab04f614ef01c3013b7d483b1d5551dd to your computer and use it in GitHub Desktop.
How to get a $33 HDMI capture and H264 encoder

This is a guide for how to get a $33 HDMI capture device and H264 encoder that can do 1080p 30 fps or 720p 60 fps. It will only output a H264 encoded stream and is not able to capture the raw HDMI data.

This is just a quick guide based on all the hard work and info from danman's blog post.

Buying

Go to ebay, aliexpress or similar and find a LKV373A sender. It is sold as a device for extending HDMI over ethernet cable. You only need to buy the sender, not the pair of sender and receiver. The sender is actually an HDMI capture and encoder device. It should cost ~$33 shipped.

Updating the firmware

The original firmware is annoying and limited. Upgrading gets you full HD resolution and ability to easily configure IP and which IP to send to (unicast or multicast).

Download the firmware linked from here or here is a direct link. You want to download everything in the directory called IPTV_command_library_and_tool_20160303.

Plug in the HDMI Extender sender to power and to your computer via ethernet.

Set your computer's static IP to e.g. 192.168.1.2 then go to 192.168.1.238 in chromium (firefox seems not to work).

Use the web interface to update the main firmware (not the encoder firmware) with the file IPTV_TX_PKG_v4_0_0_0_20160427.PKG. Wait for it to tell you it's done, then press the reset button on the device once.

It will now have a new IP address. If there is a DHCP server it will get an IP from that, otherwise it will use a 169.254.x.x IP address. You can use wireshark to listen for packets and you will see a bunch from whichever IP it picks. It might always use the same IP, in which case it will be 169.254.151.20. Give yourself a static IP in the same range, e.g. 169.254.151.2. If you have windows you can use the IPTV_Control_Center.exe utility to scan for the encoder device and find it's IP address (it did not work for me through wine and be aware that this is tricky to get working through a virtual machine since it needs to be on the same layer 2 network as the encoder).

Resetting to factory defaults

To reset the username/password to something known, you can either use the IPTV_Control_Center.exe utility and press the "Factory Reset" to the bottom right, assuming the utility detects your encoder.

Or if you know the encoder's IP address you can use telnet:

$ telnet 192.168.1.20 9999
Trying 192.168.1.20...
Connected to 192.168.1.20.
Escape character is '^]'.
==============================
========IPTV TX Server========
==============================
input>list
set_group_id        get_group_id        set_dhcp            get_dhcp           
set_uart_baudrate   get_uart_baudrate   set_static_ip       get_static_ip      
set_mac_address     get_mac_address     get_lan_status      get_hdcp           
get_video_lock      get_ip_config       set_session_key     set_device_name    
get_device_name     set_video_bitrate   get_video_bitrate   set_downscale_mode
get_downscale_mode  set_video_out_mode  get_video_out_mode  set_streaming_mode
get_streaming_mode  get_fw_version      get_company_id      factory_reset      
reboot              list                exit                
input>factory_reset
Processing factory reset!
System will reboot after few seconds!
Connection closed by foreign host.

Configuring

Access the web interface at the encoder's IP address. The username and password will be:

username: admin
password: 123456

You can change whichever settings you like. I only changed the username/password and the device's IP to 192.168.1.20. After you change the IP you have to press the encoder's reset button for the changes to take effect.

To change the destination IP where the encoded stream is sent to a normal unicast IP address you will have manually enter a URL:

http://DEV_IP/dev/info.cgi?action=streaminfo&rtp=on&multicast=on&mcastaddr=DST_IP
e.g.:
http://192.168.1.20/dev/info.cgi?action=streaminfo&rtp=on&multicast=on&mcastaddr=192.168.1.42

Now set your computer's IP to wherever you directed the stream (in the above case 192.168.1.42) and you are ready to receive.

Receiving the stream

You will need a recent ffmpeg, e.g. a statically compiled one from here.

Capture the raw video, encode audio to AAC and save as an FLV file:

ffmpeg -i udp://192.168.1.2:5004 -vcodec copy -codec:a aac -b:a 128k -f flv out.flv

This assumes your computer's IP is 192.168.1.2 and the encoder device is configured to send to that IP (and has an IP on the same subnet).

You should be able to play the video with e.g. VLC or mplayer.

Re-broadcasting to an RTMP server

To re-broadcast the unaltered video simply replace the filename with an rtmp url. For youtube this would look like:

ffmpeg -i udp://192.168.1.2:5004 -vcodec copy -codec:a aac -b:a 128k -f flv out.flv rtmp://a.rtmp.youtube.com/live2/<stream key>

streaming down-converted to 720p

You might want to transcode the video to compress it further before sending. Here's a command for transcoding to 720p 1 mbit/s and sending to youtube with the overrun_nonfatal parameter and an increased fifo_size which should protect a bit against brief service interruptions.

./ffmpeg -i udp://192.168.1.2:5004 -c:v libx264 -x264opts nal-hrd=cbr:force-cfr=1 -minrate 1000k -maxrate 1000k -bufsize 100k -b:v 1000k -vf scale=-1:720 -codec:a aac -b:a 128k -f flv "rtmp://a.rtmp.youtube.com/live2/sbjf-k8q7-phtd-4hag?overrun_nonfatal=1&fifo_size=50000000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment