Open eugenjeno opened 8 years ago
nothing?
what utility can I use to play a sound(audio file) copied to the cam. or from the SD?
I'd like to know this too. So that we can still use two-way audio communication with Yi. As this is the main purpose of this camera! Thanks! :)
from this pull looks like you do this ...
https://github.com/fritz-smh/yi-hack/pull/81/files
/home/rmm "/home/hd1/voice/wait.g726" 1
does not work, I tried it before. When running command, the cam freezes and has to be rebooted. I get the following error:
rmm_init_mpp 6604...ModId:24() is not supported !
Anyone ever figure out anything on this? I'm new to all this stuff and trying to learn....currently using Blue Iris and neither that nor TinyCam support audio back through this cam...Really wish this could be working
Also really interested in this. The RTSP streams are working well, and I like being able to cast, etc, but we're really missing the 2-way audio functionality, and I don't want to re-enable the YI app because it was opening unwelcome Play Store links on my device. Felt like spyware.
same here. looking for ways to play back audio thru camera. 👍
@cheahkhing any findings? I tried the instructions provided in issue #178 but I couldn't even play that file in the camera.
@andy2301 actually i found that i am able to play the audio file thru the camera by: For Playing back sounds thru camera: /home/rmm "/home/hd1/test/voice/wait.g726" 1 --- (for g726 file) OR /home/rmm "/home/hd1/test/voice/whatever.snd" --- (for snd file)
So, you can actually record your own sound, then convert it into the corresponding format, it should play back nicely.
@cheahkhing : what"s the cmd line that you are using?
@cheahkhing : what"s the cmd line that you are using?
as i mentioned above, just the "/home/rmm" command eg: /home/rmm "/home/hd1/test/voice/whatever.snd"
@cheahkhing Is the snd file Next/Sun au/snd? I tried some au/snd files but none work. Can you please post a working sample? Thanks. Also, the g726 used in firmware seems non standard, I tried to use ffprobe to detect the format but it fails.
请问一下你找到方法了吗?最近我做的开发也涉及到了这个功能
@hinbang recently, I decompile /home/rmm and /home/p2p_tnp and found some way to play custom audio.
/home/p2p_tnp is process handle data communicate with Mi home App /home/rmm is process to handle camera hardware device.
/home/p2p_tnp receive audio data from mi home App, then write audio data to shared memory. /home/rmm will find shared memory changed, and send audio data to hardware audio device.
I have changed the algorithm in /home/p2p_tnp. It now not read audio data from p2p network, but from file. It send audio data to shared memory and exit. Using this method, I can play g726 file, without any cam freezes.
The reason of reading audio data from file but not sending audio data to p2p_tnp by udp, because of some password in the udp payload I don't understand.
Here is the changed p2p_tnp
you can try this program ./pgmsm /home/wait.g726
/home/rmm must run background. Because rmm is the program who play audio. pgmsm just write audio data to shared memory.
@raidenii recently, I found some way to convert g726 file. You can try https://github.com/msmarks/python_g726, example/pcm2.py. It is a python3 script to convert pcm to g726.
First build python_g726, the run python pcm2.py wait.snd is will out put wait.g726.
the snd file can convert use some software, the param is in the pic bellow
thanks a lot! was trying to write a web interface to record sound and pass it to ffmpeg for transcoding. in this case then i can finish all transcoding job on backend server and just send g726 to camera. will try and update you the result!
Sent from phone
ffmpeg can also be used for converting the file to snd:
ffmpeg -i test.m4a -ar 8000 -f s16le test.snd
and then use the script + library provided by @msmarks to convert snd to g726.
I tested a couple of converted g726 <10kB in size works fine. A 111kB g726 seemingly kills rmm, though...
@msmarks Thanks for your modified pgmsm binary, but it looks like on my 47US Yi Home, its running into issues finding libstdc++.so.6, libmp4v2.so.2, and possibly other libraries. I suspect the difference is coming from different versions of base firmware on the Yi Home resulting in a dynamic linking error.
/home/yi-hack-v3/lib # /home/yi-hack-v3/bin/pgmsm /home/app/audio_file/us/success.g726 /home/yi-hack-v3/bin/pgmsm: can't load library 'libmp4v2.so.2'
Can you share the code/procedure you used to modify the p2p_tnp binary?
@ericjang Open p2p_tnp with IDA and find do_speak in Functions window. Press F5 to translate the assemble to C. As the pic bellow, this function read the audio stream from network, by calling PPPP_Read ( Line 34). Then put the audio stream to buffer, by calling MediaDataPut(Line 44).
So I changed the main function as bellow. It reads audio file then call MediaDataPut to write the buffer.
MediaDataPut needs 4 params: first param:channel,is const 5. second param:[4 bytes header] [audio data],in do_speaker, the header is always 2621696. I read 80 bytes audio data every loop from file. third param: data size. 4 bytes header + 80 bytes audio data = 84. fourth param: [4 bytes data size] [4 bytes timestamp] [16 bytes zeros],I guess. data size is same as third param which is 84, timestamp is the current audio data playing time, 80 bytes of g726 16bits audio data is 80 2 = 160 samples, the sample rate is 8000Hz, so duration is 160 / 8000 1000 = 20ms. the timestamp will be 0, 20, 40, 60 ... increase 20 every loop.
About editing main function. I use a stupid way:
I am a newbie in Reverse Engineering.
@msmarks Thanks for your modified pgmsm binary, but it looks like on my 47US Yi Home, its running into issues finding libstdc++.so.6, libmp4v2.so.2, and possibly other libraries. I suspect the difference is coming from different versions of base firmware on the Yi Home resulting in a dynamic linking error.
/home/yi-hack-v3/lib # /home/yi-hack-v3/bin/pgmsm /home/app/audio_file/us/success.g726 /home/yi-hack-v3/bin/pgmsm: can't load library 'libmp4v2.so.2'
Can you share the code/procedure you used to modify the p2p_tnp binary?
Did you found a way eventually? i have the same hardware a yi home 47us
1) how can we stream audio towards the camera from external sources. 2) how could we play an audio file g726 or wav or any format