Check out the video with demo and explanation of how to use this guide.
The goal is to send RTMP stream from an action camera (or any RTMP feed really) to the server running on Android phone and use that as a source for a video encoder (running on the same Android phone) to stream it as SRT HEVC.
To achieve this we need a server that can run on Android and a video encoder.
We'll be using MediaMTX as a server (running in Termux).
IRL Pro
is a great video encoder app. It can stream SRT HEVC with dynamic bitrate and bonding.
With IRL Pro
you'll have to be a little creative with pushing through RTMP audio.
Another option is to use ffmpeg
in Termux. It can do SRT HEVC with no dynamic bitrate and no bonding.
Disclaimer. This was mostly tested on my phone Samsung S20 FE.
MediaMTX server will be running in Termux. Install Termux on your phone. Do not use Google Play version.
Start Termux and copy-paste or type the commands below.
To copy commands open this page in the browser of your the phone and tap on commands.
To paste into Termux long tap anywhere in the Termux terminal view to bring up context menu and choose Paste
.
If at any time you need a new terminal swipe from the left edge of screen and select New session
button.
Install wget
to allow downloading MediaMTX.
pkg install wget
We need to grab linux_arm64v8
version from one of MediaMTX releases.
(Your phone can have a different architecture, but try this first.)
wget https://github.com/bluenviron/mediamtx/releases/download/v1.11.3/mediamtx_v1.11.3_linux_arm64v8.tar.gz
Unarchive it.
tar -xvzf mediamtx_v1.11.3_linux_arm64v8.tar.gz
Run MediaMTX.
./mediamtx
To stop MediaMTX tap CTRL
button in Termux and type c
.
Create a hotspot with your phone. Your camera will need to connect to your phone's hotspot (be on the same network).
Keep MediaMTX running. Open new Termux terminal by swiping right from the left edge of the screen and tapping New session
button.
Find out your phone's IP address.
ifconfig
Look for IP under swlan0
> inet
.
Configure your camera or video encoder to push to RTMP ingest of your phone.
(Replace IP_OF_YOUR_PHONE
with an actual IP of your phone.)
rtmp://IP_OF_YOUR_PHONE:1935/mystream
Start streaming your camera to MediaMTX server.
There are many ways to confirm that it works:
- Camera app would usually say if it was able to connect.
- MediaMTX will log a message in its console.
- You can open HLS url in the phone browser.
- Etc.
There are different ways to do this. Creating a service is a little a bit involved. The lazy way is to add MediaMTX to .bashrc
file. The server will start on new Termux terminal session and will be killed when you exit terminal.
nano .bashrc
Add the following line to the content of .bashrc
file.
./mediamtx
In Nano:
CTRL
+O
,Enter
to write file.CTRL
+X
to quit.
Restart Termux app or create a new terminal session to see it work.
As of June 2025 IRL Pro
doesn't have RTMP ingest feature, so this is a workaround.
Big thanks to Supairyacht
user from IRL Pro
Discord server for this idea.
We'll be pushing into RTMP ingest of MediaMTX and pulling HLS from MediaMTX. MediaMTX can do this without any extra setup.
HLS is kind of an HTML page with a video in it.
We'll create an overlay to display HLS in IRL Pro
. It can cover the whole view area if you like.
There are different ways to make IRL Pro
use audio from RTMP/HLS feed.
IRL Pro
can use only phone's "audio input". It can be built-in mic, USB audio device, mic connected via 3.5mm port, Bluetooth mic etc.
The options are:
- If all you need is a mic you can connect it directly to the phone. With this option there will be a delay of about 3 seconds between HLS video and mic, so you'll have to fix that in OBS (that has SRT media source).
- Make HLS audio play via phone's "audio output" and record it via "audio input". Video and audio should be in sync (maybe a tiny bit off, but it's a as good as it gets). I recommend getting a USB audio interface or mixer that can do this (and connect it to the phone via USB). These can be:
- Rode AI Micro. It is small, light and relatively inexpesive. Connect headphones output to mic input with a cable.
- Note about devices that use 3.5mm mic inputs. They usually expect very weak mic signal. In order to not overload the mic input set phone audio output to lowest volume first and test. Check audio levels in
IRL Pro
. Raise volume slowly and test until it's nice and loud without distorting.
- Note about devices that use 3.5mm mic inputs. They usually expect very weak mic signal. In order to not overload the mic input set phone audio output to lowest volume first and test. Check audio levels in
- Behringer Xenyx 302USB. I just happen to own one. It's relatively big, but records USB output very easily. I saw similar cheaper devices on Amazon.
- I think Behringer UCA202 is a great option for this. It is light and cheap. I don't have one to test, but pretty sure it will work. Connect audio output to input with a cable.
- IK Multimedia iRig Stream audio interface looks pretty cool. Loopback switch should do want we need.
- Rode AI Micro. It is small, light and relatively inexpesive. Connect headphones output to mic input with a cable.
- Add an overlay in
IRL Pro
. Use HLS feed from MediaMTX as an overlay source. (By default it has audio muted.)If you want HLS audio to play via your phone's audio output use this instead:http://localhost:8888/mystream
http://localhost:8888/mystream?muted=no
- Setup your
IRL Pro
to stream SRT HEVC. - Start your stream in
IRL Pro
. - If you connect mic directly to the phone add audio delay of about 3000 ms in OBS. (Note: when you test it in OBS, delay is not applied to audio monitoring, only to recording or a stream.)
- Done!
Alternative to using IRL Pro
is to use ffmpeg
in Termux.
I did a lot of tests with this option and I had a lot issues, so I'm not recommending it. Test details are at the bottom of the page.
Keep MediaMTX running. Open a new Termux terminal and run ffmpeg
in it.
Install ffmpeg
.
pkg install ffmpeg
To encode HEVC with hardware accelation use Mediacodec options. This works (* somewhat works, please see test results at the bottom) on my Samsung S20 FE for example.
Try this first (w/o -codec_name
option):
ffmpeg -i srt://localhost:8890?streamid=read:mystream \
-c:v hevc_mediacodec \
-bitrate_mode 2 \
-b:v 3000K \
-g 250 \
-pix_fmt nv12 \
-c:a copy \
-f mpegts \
srt://YOUR_SRT_URL
Different phones can have different codecs, so if that doesn't work try setting -codec_name
explicitly.
You need to look it up for your phone. Install Codec Info
app and use it to find a codec name on your phone that can do hardware accelation.
Here is what I use. -codec_name
set to OMX.qcom.video.encoder.hevc
:
ffmpeg -i srt://localhost:8890?streamid=read:mystream \
-c:v hevc_mediacodec \
-codec_name OMX.qcom.video.encoder.hevc \
-bitrate_mode 2 \
-b:v 3000K \
-g 250 \
-pix_fmt nv12 \
-c:a copy \
-f mpegts \
srt://YOUR_SRT_URL
Tweak other ffmpeg
options to your liking.
(Optional) Get more details on Mediacodec options:
ffmpeg -help encoder=hevc_mediacodec
For convenience you can create a script and manually run it.
nano ffmpeg.sh
Paste script.
while true; do
ffmpeg -i srt://localhost:8890?streamid=read:mystream \
-c:v hevc_mediacodec \
-bitrate_mode 2 \
-b:v 3000K \
-g 250 \
-pix_fmt nv12 \
-c:a copy \
-f mpegts \
srt://YOUR_SRT_URL
echo "FFmpeg exited. Restarting in 5 seconds."
sleep 5
done
In Nano:
CTRL
+O
,Enter
to write file.CTRL
+X
to quit.
Give executable permissions.
chmod +x ffmpeg.sh
Run script.
./ffmpeg.sh
To stop running CTRL
+ C
a couple of times.
Tested HLS overlay in IRL Pro
idea a bit more. Overall, it works fine.
The issue I've noticed is that it's skipping frames randomly here and there for me.
The same frame is rendered twice, so it has these micro stutters.
I had to step through frame by frame in YouTube player to see it. Untrained eyes might not notice it.
I tried to fix it by changing resolutions and bitrate in both IRL Pro
and ingest stream - no luck.
I suspect that's just how overlays work, so I don't think it can be fixed.
As for hardware acceleration for encoding HEVC when ffmpeg and Medicodec - tested that thoroughly too.
It has issues with playback of stream in OBS and SRT players. It's a little flaky. It sometimes works alright for 1080p, but needs a bunch restarts. Weird.
With libx265 -crf 23
I can get somewhat stable 480p stream, that at least is reliably playable in OBS.
This sums state of HEVC with ffmpeg in Termux on Android so far for me.
- Video guide recorded in July 2025
IRL Pro
Discord threads- This is sort of a continuation of this page that I wrote https://github.com/dimadesu/termux-nginx-rtmp (it's missing a bit with hardware accelarate options though, I'll update it someday).
- I got Mediacodec ideas from https://wiki.x266.mov/docs/encoders_hw/mediacodec