IPTSIN H.264?

Discussion about this major DATV Project. See https://wiki.batc.org.uk/The_Portsdown_Transmitter
Post Reply
M0DHP
Posts: 92
Joined: Sun Sep 24, 2017 3:25 pm

IPTSIN H.264?

Post by M0DHP » Fri Dec 15, 2017 6:30 pm

I've got vMix streaming via ffmpeg into my Portsdown. Looking at the batch file (https://wiki.batc.tv/File:VMix2Portsdown.zip), the encoding seems to be MPEG-2.

Can ffmpeg be configured to output in H.264? If so, will the Portsdown software work with it and transmit the stream in H.264?

Thanks and 73

Ray

G8GKQ
Site Admin
Posts: 2807
Joined: Sun Mar 22, 2009 1:21 pm

Re: IPTSIN H.264?

Post by G8GKQ » Fri Dec 15, 2017 9:37 pm

Hi Ray

Pleased to hear that you have vMix working with the Portsdown.

It should be possible to configure ffmpeg to encode in H264 on Windows using the libx264 encoder and this would work with the Portsdown. The things that you need to watch for are making sure that the output bitrate remains within sensible bounds and that you have enough CPU power to do it.

I have in the past successfully configured ffmpeg to software encode H264 on the RPi, but it does not have enough CPU power to do it continuously and reliably. [There are other issues related to ffmpeg hardware H264 encoding on the RPi, which is why it is not used in the Porstdown except for streaming, but these are not relevant to your question]

There is lots of info here https://trac.ffmpeg.org/wiki/Encode/H.264. The Constant Bit Rate example well down the page would provide a good starting point for experimentation. It's not something that I can work on at the moment - not enough hours in the day!

Let us know how you get on

Dave

M0DHP
Posts: 92
Joined: Sun Sep 24, 2017 3:25 pm

Re: IPTSIN H.264?

Post by M0DHP » Fri Dec 15, 2017 9:48 pm

That's great, Dave, thanks for the link. I'll let you know how it goes.

G8GKQ
Site Admin
Posts: 2807
Joined: Sun Mar 22, 2009 1:21 pm

Re: IPTSIN H.264?

Post by G8GKQ » Fri Dec 15, 2017 9:56 pm

Ray

I've just found the code that sort of worked on the RPi. You'll need to "translate" it as a lot of the parameters where set using environment variables, but it may help:

Code: Select all

            sudo nice -n -30 $PATHRPI"/ffmpeg" -loglevel $MODE_DEBUG -itsoffset "$ITS_OFFSET"\
            -analyzeduration 0 -probesize 2048  -fpsprobesize 0 -thread_queue_size 512\
            -f v4l2 -framerate $VIDEO_FPS -video_size "$VIDEO_WIDTH"x"$VIDEO_HEIGHT"\
            -i /dev/video0 -fflags nobuffer \
            \
            -f alsa -ac $AUDIO_CHANNELS -ar $AUDIO_SAMPLE \
            -i hw:$AUDIO_CARD_NUMBER,0 \
            \
            -framerate 15 -video_size "$VIDEO_WIDTH"x"$VIDEO_HEIGHT" \
            -c:v libx264 -b:v $BITRATE_VIDEO -minrate:v $BITRATE_VIDEO -maxrate:v $BITRATE_VIDEO \
            -g 25 \
            -c:a mp2 -b:a 64K -ar 44100 -ac $AUDIO_CHANNELS\
            \
            -f mpegts  -blocksize 1880 \
            -mpegts_original_network_id 1 -mpegts_transport_stream_id 1 \
            -mpegts_service_id $SERVICEID \
            -mpegts_pmt_start_pid $PIDPMT -streamid 0:"$PIDVIDEO" -streamid 1:"$PIDAUDIO" \
            -metadata service_provider=$CALL -metadata service_name=$CHANNEL \
            -muxrate $BITRATE_TS -y $OUTPUT &
Dave

M0DHP
Posts: 92
Joined: Sun Sep 24, 2017 3:25 pm

Re: IPTSIN H.264?

Post by M0DHP » Sat Dec 16, 2017 11:06 am

Hi Dave

I've got it working! Here is the ffmpeg call I'm using, in a cut down version of the batch file ...

Code: Select all

C:\ffmpeg\bin\ffmpeg ^
-rtbufsize 1500M ^
-f dshow -i video="vMix Video" -f dshow -i audio="vMix Audio" ^
-c:v libx264 -x264-params "nal-hrd=cbr" -preset ultrafast -pix_fmt yuv420p -r 25 -s 768x576 -aspect 4:3 -qmin 2 -qmax 35 ^
-b:v 1200K -minrate 1200K -maxrate 1200K -bufsize 2400K ^
-c:a aac ^
-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="BATC" -metadata service_name=%callsign% -y udp://%ip%:10000?pkt_size=1316
These rate settings give a bit rate of around 1350kbit/s according to the ffmpeg status messages. I chose this to be just a bit lower than the bit rate I've seen when using the standard MPEG-2 batch file at 1000kS/S and 7/8 FEC.

I'm running vMix, ffmpeg and MiniTioune on the same, rather elderly laptop with Windows 10. To keep the CPU utilisation below 100%, I've used the H.264 ultrafast preset. I can get away (just) with veryfast but it didn't make a noticeable difference to the image quality.

My source video is the built-in webcam, so not great quality. But the decoded image on MiniTioune seems no worse quality than the source.

One thing that isn't working is the audio. MiniTioune thinks an audio stream is there, because setting MiniTioune to the wrong audio PID or audio codec type stops the decode completely.

My next step is to experiment with higher and lower bit rates (for use at 2000kS/s and 333kS/s), and then produce a "proper" update to the batch file to do rate switching and give the option for MPEG-2 vs H.264.

73

Ray

G8GKQ
Site Admin
Posts: 2807
Joined: Sun Mar 22, 2009 1:21 pm

Re: IPTSIN H.264?

Post by G8GKQ » Sat Dec 16, 2017 6:31 pm

Well done Ray!

Have you considered using a different audio codec? Earlier versions of MiniTioune did not support aac.

It would be great if you could add your completed script to the Wiki page here https://wiki.batc.org.uk/Feeding_Video_ ... _from_vMix Edit - URL corrected

Thanks

Dave

M0DHP
Posts: 92
Joined: Sun Sep 24, 2017 3:25 pm

Re: IPTSIN H.264?

Post by M0DHP » Sat Dec 16, 2017 7:16 pm

Thanks for the suggestion about the codecs - I'll try that. I better also check that there is some audio in the stream in the first place - I've assumed that vMix is outputting it but will need to think of a way of confirming this. (EDIT: changed the script to stream to VLC player - audio OK - so will focus on the codecs)

And I will add the script to the wiki once I've done some more testing. I've also done some initial tests with MPEG-2 at 333kS/s so will include those changes too.

M0DHP
Posts: 92
Joined: Sun Sep 24, 2017 3:25 pm

Re: IPTSIN H.264?

Post by M0DHP » Sat Dec 16, 2017 9:52 pm

Found easy fix for the audio :-( Moved MiniTioune to different PC from vMix.

MPA working on MPEG-2 and AAC on H.264 (MiniTioune 0.7b).

OE3GBB
Posts: 8
Joined: Wed Jun 07, 2017 1:01 pm

Re: IPTSIN H.264?

Post by OE3GBB » Thu May 09, 2019 2:45 pm

I would like to include 500kS into the batch file. What are the VIDRATE-values?

Post Reply

Return to “The Portsdown Digital ATV System”