Using Tronsmart Pavo M9 for HDMI input streaming

Thanks to a tip of my reader, I found a relatively cheap (69Eur) Android box with HDMI input and record ability. I thought that it should be possible not only to record the HDMI input but also to stream it in realtime so I ordered one for experimenting.

Disassembly

The device came without any box, just in bubble foil but it doesn’t matter to me if it keeps the cost low. You can find functional review of the device on cnx-linux page.

Bottom side of PCB:

Upper side with heatsink:

Upper side without heatsink:

As you can see from the pictures, device uses MSO9180D1R SoC for which I couldn’t find any datasheet. The traces from HDMI input go directly to the SoC which is a good sign, that the signal is not converted to analog form (at least outside the SoC).

First steps

HDMI recording app is available directly from main menu and offers recording in MP4 or TS (mpegts) format, both with H264 video and AAC audio. MP4 format is not suitable for streaming (at least not until the recording is finished) because the metadata of file is written only after the recording is finished. On the other side, TS is ideal for streaming because data is segmented into properly formated 188bytes packets.

To gain shell access, I installed SSH Server from Google Play which worked without any problems. After connecting, I was easily able to gain root access to device because the devices comes pre-rooted from factory.

First stream

Ok, my goal was to stream live from HDMI so I thought it might be possible to just pipe tail of recorded TS file to network (preferably multicast) and see if it works. So I installed BusyBox Free from Google Play (to get nc utility). It showed up, that nc from busybox supports only TCP connections (and of course the segmentation to TS packets won’t be good) so this will not be a way.

After a while, ffmpeg came to my mind: you can specify output packet sizes there and in general it’s designed exactly for streaming/encoding and I have seen it used on Android before. So I googled ffmpeg precompiled binary, downloaded it and put it on my USB key to run it from shell.

First, I started VLC on my computer like this:

vlc udp://@239.255.0.1:1234

Then I started recording in “HDMI IN” application (which created recording file in /sdcard/HdmiRecorder/video20151227161832.ts) and then run ffmpeg in device shell:

But when I stopped vlc, and tried to join the stream again, vlc was unable to start decoding video (audio was playing fine). I did a short analysis of the .ts file and found out, that it contains h264 metadata (SPS, PPS, more on this here) only in the beginning of the file and if these are not received by vlc, it doesn’t know how to decode the h264 bitstream.

Analyzing recording application

In Android, all apps are stored as .apk files in system folder. HDMI IN recording app is not an exception (/system/app/ZidooRecord.apk), so I downloaded it to my computer and decompiled it using http://www.decompileandroid.com/ (great tool, thanks to the author).

Side note: To avoid confusion here, Zidoo X9 is product from Zidoo company built on top of the same HW platform from company called Mstar who developed the SoC. So Tronsmart is the same HW platform with the same software just sold under other name/company.

Those github sources include binary library integrated with Android using NDK which allows recording from HDMI. The binary is very briefly documented and sources are available only to distributors with signed NDA so I have struggled with cutting the sources to minimum and compiling it myself. But finally I succeeded building my own recording app. https://github.com/danielkucera/ZidoStreamer

I was hoping that I’ll be able to change the recording format so it contains correct extradata before each keyframe but it wasn’t possible (more info here). After start, my app successfully started recording to file and started ffmpeg which streamed it to network but this was little improvement compared to where I was with original app, I still had to catch the beginning of the stream otherwise the stream didn’t work. So I came back to experiment with ffmpeg.

The point is: tail starts to read recorded file from beginning (-c 1000000000) and keeps reading on (-f) while piping to ffmpeg which reads from stdin (-i -), create correct extradata before each keyframe (-bsf:v dump_extra – this is the key!) and stream to network as mpegts stream (-f mpegts udp://239.255.0.1:1234)

What we have now and where we go

So for now, we have a working android app that starts recording from HDMI input using proprietary binary and working ffmpeg command to create playable stream.

My target is to create app which will be able to start recording without that binary (it should be possible according to some tests I did), set different bitrates/resolutions, omit the recording to file (use just fifo file to avoid flash memory speed bottleneck and limited size – done some successful tests, just need to fix bugs) and allow different output stream types, e.g. rtmp, udp mpegts unicast, tcp mpegts unicast, rtp etc. (this all can be handled by ffmpeg, just needs to be correctly setup). So for now, I have “proof-of-concept” and a plan.

If you are interested in this or want to help, feel free to comment, fork, push commits, whatever.

119 thoughts on “Using Tronsmart Pavo M9 for HDMI input streaming”

Hi danman,
great article.
It is very helpful that you are describing the way, how did you come to the conclusion.
I am very interested in the target app.
When you put in on google app store, i would buy it. 🙂
There are many users who want to have such an app.
Because, timeshift is not possible with the zidoo app.
And with a stream, i can stream to my htpc and use for example kodi and a timeshift plugin.
Alternatively: it is possible to stream to 127.0.0.1 and then use timeshift with the installed version of Kodi and a timeshift plugin on the box or is the box too slow ? (So that the app works in background?)
Nice greetings André Lehrmann

Hi,
this sounds very interesting.
With your modified zidoostreamer, is HdmiRecorder/* the stream from when you start the streamer?
So when you pipe that into ffmpeg, ffmpeg will start streaming it from the beginning of that ‘recording’, rather than ‘live’ what is coming in through the HDMI, or am I seeing that wrong?

Great project and post.
I’m quite interested on following your progress on this but can’t seem to find some kind of “follow” button on your blog.
By the way, the photos you posted aren’t showing up, at least on my side.

thanks for the post. I didn’t know the devices that could do recording from hdmi got this cheap.
Just ordered one for myself.
I’m not an expert at this but looking at your pastebin dump it looks likes the hdmi in registers as “Linux video capture interface: v2.00”.
This should mean that you don’t need the recording app and can directly use ffmpeg “ffmpeg -i /dev/video0” to grab the video from the input.
Most likely there won’t be any audio but this can be fixed with “ffmpeg -f alsa -i hw:0,0 -f v4l2 -i /dev/video0”

I have the X9S (zidoo), which doesn’t have the /dev/video0 device but it does have a /dev/video250. After more investigation in the filesystem (/sys/devices/virtual/video250 etc) it seems that that is the input device.

However, using ffmpeg in Termux I can’t access the device as it seems that it’s a build without v4l2 support.

Images don’t show up because the default entry into the site redirects to https:// version but the image URLs are hard-coded to plain http, so won’t display. Once you’re in the site just remove the ‘s’ from the https and all is good, which confirms.

Do you know if there is any delay between the input and output streams? I would love to use this as an easy recorder for my computer but I do not want any additional delay between my desktop and monitor.

So it would be sit between my desktop and monitor. And record/output to either network or a separate attached drive. What I am looking for is 0 lag. I know that might be a tall order.

Thank you for your post!
A friend just linked me to the device on the ebay and then linked me to your post about it. I happened to catch your youtube live stream just now while it was online and it ran great at 1080p!
Though I’m curious if you have any thoughts on streaming from a Windows machine through the Pavo M9 device to Twitch.tv?

cool! I have been reading the source code of the zidoo recorder… I want to add recurring scheduling to it and eventually adding streaming.. It’s cool to see you have made a lot of progress and you seem to have much more experience with streaming than me .. will follow the progress of the zidoo streamer and will try to contribute if I find something interesting

hi, many thanks! for your post and basic insides of this little gadget. I have successfully used two of these boxes as a user-simple solution to stream live HD videos across the network. After some hacking and testing i have managed to stream in the real time without need of ffmpeg nor any other natives .. just regular MediaRecorder, MediaPlayer and java. In essence the transmitter (MediaRecorder) is providing the encoded TS data to the receiver (MediaPlayer) using extremely lightweight http-like server, where the receiver is “downloading” the A/V file of a infinite length.

hi, in english for other public out there. The application is working prototype and “as is”. After launch, there are two options to choose: Transmit and Receive. Click Transmit from where you want to stream and click Receive where you want to view live stream. After that, applications will automatically negotiate and establish network connection and start playback when located in the same network. Sources here: http://uloz.to/xsivHBrj/videobox-2016-02-14-zip

Hi Tomas, Danman! Great work! Thanks to you both!!! Here is few questions:
to Danman: will you rewrite code as Tomas offer? With using internal android class, without no need of ffmpeg? Is it possible? Also, could you add ONVIF support, so another devices could simple find our little broadcaster and gets picture from it?

to Tomas: the app work like a charm, but is it possible to add buffer length changing control? Then i can’t install this apk to android 4.4 and 5.0 smartphones, but it installed correctly on android stick with 4.1.2, where could be a problem?
Is this app support multiply receivers? Also, how could i get stream on another devices? For example, winPC or Mac? Is there VLC string to show it up?

Hello, this app was not ment to be working end-user software solution. I have created this piece of software in order to explore capabilities of the Pavo M9, to live stream A/V media acquired from the HDMI input over the local network. The provided sources in the given form are highly deppendent on the Pavo M9 HW/SW platform .. at least for recording.

The app may not be possible to install to another Android platforms due to missing built-in “android.uid.system” user account (defined in the app manifest), which is apparently required in order to reach the Pavo M9 HW.

My requirements were to use as minimum buffering as possible (no delays), but yes, some extended buffering can be added. Same as the other app preferences, which are at this moment hardcoded. The A/V stream can be played using VLC or any other media player which supports network streaming at address: http://[pavo-m9-ip]:12345/

At this time, only one host may connect to the streaming server. In theory, this may be possible to change, but this do require parsing of the A/V stream in order to properly initiate the streaming session when a host join in middle of the streaming (where the A/V stream no longer contains the metadata).

You must understand, that the Android platform provide limited resources and possibilities to record and play the A/V content. Android by default does not provide any layer to transport the A/V content across the network. This is done using some “clever” exploitation of the http protocol. You can use some native helper applications (as the Danman did), but i wanted to avoid it.

Thanks for the app and the work! just two comments on my side:
first I do not why but the config does not open when I select it. Have you experienced the same?
secondly, I can open the stream from VLC on my PC but I have another tv box from my internet provider and VLC does not have the option to define the stream to read. What other app could you advise me to read the stream from another tv box that is not the tronsmart?

Can somebody describe little bit more about how app can became working.
Already I installed signed.apk to my Pavo m9. In application settings I found only option for (mp4 or ts) , address.
I choose ts and udp://239.255.0.1:1234
After that i try to connect with VLC but no success.

With ZidoStreamer I cannot get working with any address. Probably I missing something.

This is what I’m doing

Start VLC on my PC
Start ZidoStreamer on Pavo M9 and click Menu Button on remote control , There I can see 2 settings: Video type and Streaming address. I chose TS for video and udp://239.255.0.1:1239 or udp://172.16.20.232:1239 . I tried with @ before the IP and there no difference.

Thank you very much for suggestion.
I found the problem with logread, it was missing ffmpeg in /data/data/eu.danman.zidostreamer.zidostreamer/files/ffmpeg , after I copied ffmpeg binary , stream bacame working 🙂
My question is can I modify quality to something low because it’s glitch when I’m using WiFI? Probably my WiFi is not good and streaming require more speed.
When both devices are connected on LAN , picture is perfect.
Another questing is can I use another protocols other than UDP:// and how I can do that. Currently I’m using udp://@172.16.20.232:1239

glad to hear that. For now, the quality is hardcoded into app, but my plan is to make it adjustable in settings. You can theoretically use any type of output which is supported by ffmpeg. But for now also this cannot by set in settings, you would need to change it in code, but good point to change this also.

Thank you for update.
Is it possible in next update you to include option for screen resolution 🙂
Another thing which I saw , after I exit from ZidoStreamer still I hear the sound from HDMI, it looks like the app not stops.

Off topic: Does the WiFi working on your device, because after I made the upgrade to v1.0.3.07 it cannot start and show mac address 00:00:00:00:00:00 ?

I didn’t notice it before, but so do I have the same distortion in recordings. And the original recording app also records with distortion. Maybe some system update can fix this. This seems to me like a HW/system bug.

Hi Guys! Software by Danman and Thomas works well. In my opinion, you should merge their functionality in one app: give user too chose native or ext encoding type.
There is a question: could it work in a background? Because when i click “home” button and run another app, it’s stops.
Also, is h.265 capabilities in ffmpeg? Could it software encode hevc on our box smoothly?

How can I get a piece of this device with HDMI IN streaming enabled. My demo requirement is that the device should be able to take HDMI IN from another STB or a camera and then stream out h.264 packets over RTMP OR RTSP OR HTTP to a WOWZA instance. I should then be able to view the video by accessing the WOWZA URL on any client machine.

You can go buy one and install my app as described on github page. Wowza shoud work fine with rtmp output from this device. Let me know if it works for you. But notice, there are still some issues with sound distortion. I hope, the producer will fix this with firnware update.

Will your APK and library work as it is on ZIDOO X9 based on A9 MSTAR MSO9180D1R UP, 1.5GHz as well. Tronsmart Pavo 9 does not seem to be in stock at the moment. Just called up their China office to find out.

Hi,
my app doesn’t use NDK anymore. You just need to open camera with id 5 (which is not listed when you request camera list) and have your apk signed with mstar key to be allowed to access that camera.

I tried your application on ZIDOO X9 A9 MSTAR MSO9180D1R box, sometimes the application unable to start the recording and shows the message “failed to start recording”. Is that anything wrong in the application? or do i need to setup any configuration for this?

I’ve been looking for a slingbox alternative that would work well with a linux client. it seems like this could work, though it seems under construction. I have a really hard time searching for alternatives, I usually get like 90% chrome-cast style results. Do any of you know of any good alternatives? Do you think this will ever really be a replacement, it seems really cool, though, I wonder if it’s powerful enough, I always ran into not enough resource issues when trying to do …………..
The Pavo M9 has an IR blaster for changing the tv/box channels, right? never know how accurate the product descriptions are.

Hi Danman ,
thanks for the app, really helpful .
I have a question, i’m using the app not to stream but to preview the hdmi input from another android tv box . I could preview the hdmi input fullscreen , but as per our requirement the preview should be 75% of the screen , and the rest 25 % we have an image slide show . Could you please help me and tell how to change the preview size of the hdmi input .
thanks in advance .

Hi danman,
I hopy you can help me.
The important stuff:
Have you an idea why the picture is shrinking?
I have an Zidoo X9 with firmware 1.0.4.2. I deinstalled the Kodi 14 and installed Kodi 16 with play store. Then I started the zidoostreamer with the ffmep option 239.254.0.1:1234. Then i started kodi, goes to system -> addons -> enable the IPTV simple client (that comes with kodi). The IPTV Simple client reads a m3u file, which i created, with content udp://@239.254.0.1:1234. Under sytem -> livetv i activate the TV function of kodi.
When i now go to TV and choose the zidoostreamer channel the picture appears, then black screen, then a smaller picture appears, then black screen, then smaller and so on. In the end i have a black screen.
Normal IPTV runs, also with zidoostreamer in the background running.
With my manual you can reproduce this situation.
Also i make a video with my handy where you can see the shrinking picture and the normal livetv:
Not so important stuff: https://vimeo.com/164077248
When i use zidoostreamer (regardless wifi or ehternet) i become on networkclients (Windows 7 and Debian wheezy) many errors in the vlc log, The picture is not usable, stucks and so on. No Livestream possible.
I know that the x9 has a network problem, so i read your post and the hint that the tronsmart has the same hardware. So i flashed the Pavo M9 firmware on my x9. But when i start the x9 there is a message (i think fom the menu ui) the authentification failed. So i cant test it with the Pavo M9 firmware. Then i flashed the normal X9 firmware back.
Do you have network issues?
When i copy a file with ssh scp i have only 2,5 mbyte, regardless wifi or ethernet. What is your network performance with copy a file with scp?
When it is better, I think the problem is in the firmware.
I used the precompiled ffmpeg from you http://blog.danman.eu/wp-content/uploads/ffmpeg-android.tgz which i downloaded months ago. Evtl. you have a new version?
Nice greetings,
AL

I doubt there is some standardized way how to stream TO http server (I mean create some HTTP POST with data in body or so…). But you can start pure TCP server (e.g. with nc in linux) and push the data to the server using ffmpeg tcp module https://ffmpeg.org/ffmpeg-protocols.html#tcp . This way, the data should be reliably delivered to the server.

hello, I want to do a project. I want input as HDMI TV TDT signal, that signal processing to put on her images or videos, which is displayed by the HDMI output. Would it be possible? Where do we have to start?

I’m having some problems: HDMI-in is installed, the DSLR attached to it is showed on Monitor.
But you app do not work, I click on it, it starts, blank screen comes and goes back to app menu..
I would appreciate, if we could make it together one step-by-step install and configuration.
ssh-server is running on Android-box. VLC udp, does nothing
THX

I will try it.
I have ssh access, maybe you can tell me witch command I have to put on terminal to get this app?
I installed also rom manager, but it doesn’t seems to work properly on this box? should i try to flash a specific custom rom?

Hi, did you know if it’s possible to get hdmi input source and send it to a textureview? because we’ve tryed for many hour but it seems to work only on a surfaceview 🙁 . Can i contact you with a private message or mail? i need some help on this and i don’t know how to solve it!
Thanks!

I have tried various resolutions, removing audio, decreasing the video encoding bitrate… but i still have a delay around 2.5 seconds.
I suspect it is related on the read/write buffers, not on the encoding operation itself.
Do you have any idea on how I could work around this?

Hi Danmen,
When i try to stream the video i got the following warning message continuously from ffmpeg….
“Non-monotonous DTS in output stream 1:1; previous: 2234108, current: 2230257; changing to 2234109. This may result in incorrect timestamps in the output file”.
Is there any way to resolve it…..

I have the same problem, timestamp is altered. When watching the stream on my computer after an hour I have a delay of 5 sec at least and 10 sec after 2 hours. It became realy hard to switch tv chanel since so much delay, I simply restart the stream in kodi. My zidoo is plug with ethernet to my computer ( 2 ethernet cable) with default setting from windows 10 for network.

I get the same warning as Pranesh Kumar: “Non-monotonous DTS in output stream 1:1; previous: 2234108, current: 2230257; changing to 2234109. This may result in incorrect timestamps in the output file”. Not with the same numbers, but the warning is the same. Please help.