New approach to H265 for the Portsdown

Discussion about this major DATV Project. See also https://wiki.batc.org.uk/The_Portsdown_Transmitter
G7JTT
Posts: 148
Joined: Fri Jun 10, 2016 5:05 pm

New approach to H265 for the Portsdown

Post by G7JTT » Sun Dec 01, 2019 10:39 am

Hi all over the last few weeks I've been playing with a Jetson Nano to encode the H264 from OBS to H265 and then onto the Portsdown via IPTSin. Below is what I've come up with, which although works is still in a early stage of development.

Hardware needed
Portsdown 2019
Jetson Nano (with 5v 2.5mm jack, not a micro USB PSU)
Router and Leads
Laptop/PC

Software needed
Cmake sudo apt-get install cmake
Nginx https://harry.web.id/2018/11/18/ubuntu- ... p-vod-hls/ (Only follow instructions up to add rtmp server to nginx.conf)
Ffmpeg for the Jetson Nano https://github.com/jocover/jetson-ffmpeg
OBS https://obsproject.com/download

Start with setting up a network between the computer, Jetson nano and the portsdown. If your router allows set each device up with a fixed IP as this will help with keeping the scripts happy later on.

Now install cmake, Nginx and ffmpeg on the jetson nano, your’ll need to remember where you install these as the addresses are need later on. Also install OBS on to your computer as well.

OBS Setup
Create a profile and call it something like Nano, then go to settings, stream and select service as custom. Next to server enter rtmp://Jetson nano ip address/live, so it will look something like rtmp://192.168.1.105/live. Now next to stream key type nano or whatever else you chose to call the stream. Whilst still in settings go to the video tab and set output resolution to some this sensible for the SR/FEC combo you are going to use. For FPS I find 250Ks and above 20FPS works well, whilst 15FPS is best for 125Ks and below. Next go to the output tab, output mode and select advanced. Now set up the values in the image below.
Settings OBS.jpg
Settings OBS.jpg (96.75 KiB) Viewed 769 times
Please note these values work for me but may need tweaking for your setup. Whilst still in “output” select the audio tab and set track 1 audio bitrate to 96. You may also want to set the audio to mono in the audio tab depending on your needs.

Jetson Setup
Install cmake first then both Nginx and ffmpeg, then create a script call it SR_FEC.sh so the example below would be 333_34.sh e.g 333Ks and 3/4 FEC.

Code: Select all

#!/bin/bash

./ffmpeg/ffmpeg -i rtmp://192.168.1.105/live/nano -c:v hevc_nvmpi -preset fast -b:v 445k -maxrate 445k -bufsize 250k -muxrate 525k -c:a copy -f mpegts -mpegts_original_network_id 1 -mpegts_transport_stream_id 1 -mpegts_service_id 1 -mpegts_pmt_start_pid 4096 -streamid 0:256 -streamid 1:257 -metadata service_provider="QO-100" -metadata service_name="YOURCALL" -flush_packets 0 -f mpegts "udp://192.168.1.103:10000?pkt_size=1316"

First set the path to ffmpeg in my case its ./ffmpeg/ffmpeg. Then change the muxrate and the video bitrates (in the example above 445K). YOURCALL easy enough it’s your callsign and lastly the ip address is the ip and port address of the portsdown. To make the script executable use the command chmod +x 333_34.sh then to run type ./333_34.sh from a terminal window. On 125Ks and below it also helps to reduce the audio bitrate and this is done by replacing -c:a copy with -c:a aac -b:a 32k.

Portsdown Setup
Easy just select IPTS in on the Encoder tab and the correct frequency, SR and FEC for the script you are using on the Jetson.


Running it !
Start OBS up but don’t start streaming yet, on the Jetson open up a terminal window and start the RTMP server. On my setup that’s done with sudo /usr/local/nginx/sbin/nginx, if all goes well you should be back at a prompt. Now start your script of choice ie ./333_34.sh, then start the streaming on OBS all going well you should see the ffmpeg start processing the stream from OBS. Now just follow you normal Tx process.

Whilst this has worked on my system with the above info you may need to tweak all or some of the above to get it to work for you. Also I’m no expert on any of this and I’m sure someone can improve upon what I’ve done and any improvements will be gratefully received. Lastly have fun and keep playing.

All best John G7JTT

G7JTT
Posts: 148
Joined: Fri Jun 10, 2016 5:05 pm

Re: New approach to H265 for the Portsdown

Post by G7JTT » Sun Dec 01, 2019 10:50 am

This May also be of use as well I wrote a simple menu system to save having to remember all the filenames and commands the script is below. There are also a couple of options to display the incoming RTMP stream and the UDP stream from LongMynd (for H264/5 decoding) its full screen cant seem to get Gstreamer to output the video in a windowed mode ?

Code: Select all

#!/bin/bash
# bash menu script example

/usr/local/nginx/sbin/nginx

resize -s 15 125

PS3='Please enter choice:'
options=("35Ks" "66Ks" "125Ks 5/6 FEC" "250Ks 3/4 FEC" "333Ks 2/3 FEC" "500Ks 1/2 FEC" "LongMynd" "rtmp view" "Quit")
select opt in "${options[@]}"
do


    case $opt in
        "35Ks")
            ./rtmp35.sh
            ;;
	"66Ks")
            ./rtmp66.sh
            ;;
        "125Ks 5/6 FEC")
            ./rtmp125.sh
            ;;
        "250Ks 3/4 FEC")
            ./rtmp250.sh
            ;;
	"333Ks 2/3 FEC")
            ./rtmp333.sh
            ;;
        "500Ks 1/2 FEC")
            ./rtmp500.sh
            ;;
        "LongMynd")
            gst-launch-1.0 playbin uri='udp://192.168.1.105:1234'
            ;;
	"rtmp view")
            gst-launch-1.0 playbin uri=rtmp://192.168.1.105/live/test
            ;;
        "Quit")
	/usr/local/nginx/sbin/nginx -s stop	
	xdotool getactivewindow windowkill
            ;;
        *) echo "invalid option $REPLY";;
    esac
done

CU2ED
Posts: 6
Joined: Thu Jan 17, 2019 11:30 am

Re: New approach to H265 for the Portsdown

Post by CU2ED » Mon Dec 02, 2019 12:41 pm

Hi John,

well, first small presentation about me, my name is Jacinto, I live in Azores (HM77FR) and I always saw ATV and now DATV as very interesting mode, but due to the lack of activity on my country, I never started this mode, now with the QO-100 this's my opportunity to try.

Thank you for this new how-to, will be very useful for me with my jetson board and I will try next weekend, for now, I'm collecting more information on how to start from the begin with the board.

73

Jacinto
CU2ED
G7JTT wrote:
Sun Dec 01, 2019 10:50 am
This May also be of use as well I wrote a simple menu system to save having to remember all the filenames and commands the script is below. There are also a couple of options to display the incoming RTMP stream and the UDP stream from LongMynd (for H264/5 decoding) its full screen cant seem to get Gstreamer to output the video in a windowed mode ?

Code: Select all

#!/bin/bash
# bash menu script example

/usr/local/nginx/sbin/nginx

resize -s 15 125

PS3='Please enter choice:'
options=("35Ks" "66Ks" "125Ks 5/6 FEC" "250Ks 3/4 FEC" "333Ks 2/3 FEC" "500Ks 1/2 FEC" "LongMynd" "rtmp view" "Quit")
select opt in "${options[@]}"
do


    case $opt in
        "35Ks")
            ./rtmp35.sh
            ;;
	"66Ks")
            ./rtmp66.sh
            ;;
        "125Ks 5/6 FEC")
            ./rtmp125.sh
            ;;
        "250Ks 3/4 FEC")
            ./rtmp250.sh
            ;;
	"333Ks 2/3 FEC")
            ./rtmp333.sh
            ;;
        "500Ks 1/2 FEC")
            ./rtmp500.sh
            ;;
        "LongMynd")
            gst-launch-1.0 playbin uri='udp://192.168.1.105:1234'
            ;;
	"rtmp view")
            gst-launch-1.0 playbin uri=rtmp://192.168.1.105/live/test
            ;;
        "Quit")
	/usr/local/nginx/sbin/nginx -s stop	
	xdotool getactivewindow windowkill
            ;;
        *) echo "invalid option $REPLY";;
    esac
done

G7JTT
Posts: 148
Joined: Fri Jun 10, 2016 5:05 pm

Re: New approach to H265 for the Portsdown

Post by G7JTT » Mon Dec 02, 2019 7:49 pm

Ok Jacinto hopefully your get it working if you have any issues post on here and I'll help as best I can.

73 John G7JTT

CU2ED
Posts: 6
Joined: Thu Jan 17, 2019 11:30 am

Re: New approach to H265 for the Portsdown

Post by CU2ED » Mon Dec 02, 2019 8:30 pm

Hi John,

I just want to know what is the image you are using, is the jetson-nano-sd-r32.1-2019-03-18 ???
I did see on batck wiki some reference to this version, it's important or I can use the last one that is on the jetson nano page:
https://developer.nvidia.com/embedded/l ... vkit#write

73 Jacinto
CU2ED

Ok Jacinto hopefully your get it working if you have any issues post on here and I'll help as best I can.

73 John G7JTT
[/quote]

G7JTT
Posts: 148
Joined: Fri Jun 10, 2016 5:05 pm

Re: New approach to H265 for the Portsdown

Post by G7JTT » Tue Dec 03, 2019 11:23 am

Hi Jacinta it's the latest image from the nvidia website only had the nano a few weeks .

73 de John G7JTT

CU2ED
Posts: 6
Joined: Thu Jan 17, 2019 11:30 am

Re: New approach to H265 for the Portsdown

Post by CU2ED » Fri Dec 06, 2019 11:25 am

Hi John,
yesterday I had an opportunity to try the jetson nano board and it worked for the first time ...with my webcam (C920) it's almost OK but if I produce high movements or I insert on OBS a video with very quick movements I'm seeing a lot of dts > pcr TS invalid messages (ffmpeg jetson board) which result in dropped frames, so I suppose have to adjust some parameters ... 

73,

Jacinto
CU2ED

G7JTT
Posts: 148
Joined: Fri Jun 10, 2016 5:05 pm

Re: New approach to H265 for the Portsdown

Post by G7JTT » Fri Dec 06, 2019 7:21 pm

Hi Jacinto glad its working (to a fashion) try to adjust the bitrate start at 300 and increase 50 at a time untill you find what suits your set up.

All best John

G4WIM
Posts: 284
Joined: Thu Jan 29, 2015 8:36 pm

Re: New approach to H265 for the Portsdown

Post by G4WIM » Fri Dec 06, 2019 9:08 pm

Hi Jacinto

I've been battling dropped frames and dts > pcr TS invalid errors.

At Mike G0MJW suggestion I increased the pcr_dts value in the jetson_nano.sh script from 200000 to 400000 and as a result after 1 hour of running at 1MS I have seen no dts > pcr errors and as far as I can tell no dropped frames.

73 Tim

CU2ED
Posts: 6
Joined: Thu Jan 17, 2019 11:30 am

Re: New approach to H265 for the Portsdown

Post by CU2ED » Sun Dec 08, 2019 8:54 am

Hi Tim,

Thank for the information, my setup at the moment (instructions from G7JTT) don't use dvbsdr so, with porstdown I don't know
where is this variable, after changing bitrate video (to 275 in my case) I was able to reduce almost zero this problem, the delay is not bad but the video quality is not the best with my C920, so I decided to try dvbsdr (another SD card with new image) it worked at first time with picam V2 then I tested VIDEOSOURCE IP with OBS and again it worked OK, the delay is almost the same (3 seconds) and the image quality is better, I also had dts_pcr invalid errors messages and a lot, I increased to your value and it seems much better but again, sometimes it appear, only if I increase to 1000000 I can have almost zero, but it increases the delay a little !!!
Finally, I tried the FPGA image for limesdr and the quality is indeed better but it increases the delay to 8 or 9 seconds, at least with all my hardware, this is with OBS studio, with picam V2 I go from 2 seconds to almost 5 seconds ...


73
Jacinto
cu2ed

Post Reply

Return to “The Portsdown Digital ATV System”