{"id":206,"date":"2020-04-16T20:39:04","date_gmt":"2020-04-16T13:39:04","guid":{"rendered":"https:\/\/prosindo.com\/blog\/?p=206"},"modified":"2020-04-18T13:52:31","modified_gmt":"2020-04-18T06:52:31","slug":"two-way-audio-with-xiaofang-hack","status":"publish","type":"post","link":"https:\/\/prosindo.com\/blog\/2020\/04\/16\/two-way-audio-with-xiaofang-hack\/","title":{"rendered":"Two Way Audio with XiaoFang Hack"},"content":{"rendered":"<p>XiaoFang IP Camera with samtap&#8217;s fang-hacks (https:\/\/github.com\/samtap\/fang-hacks), you can get 2-way audio with a little trick:<\/p>\n<p>1. download necessary files (from https:\/\/github.com\/samtap\/fang-hacks\/issues\/305) and put it on \/media\/mmcblk0p2\/snx_audio (dont forget to set permission execute):<br \/>\n<code>- snx_audio_playback<\/code><br \/>\n<code>- snx_audio_record<\/code><\/p>\n<p>2. remote speaker:<br \/>\n<code># set gpio<\/code><br \/>\n<code>gpio_ms1 -n 7 -m 1 -v 1<\/code><br \/>\n<code># listen audio data in port 11032 on camera<\/code><br \/>\n<code>tcpsvd 0.0.0.0 11032 \/media\/mmcblk0p2\/snx_audio\/snx_audio_playback -d s16 -s 32k -f -<\/code><br \/>\n<code># stream audio from pc to camera<\/code><br \/>\n<code>ffmpeg.exe -i input -ar 16k -f s16le tcp:\/\/your-cam-ip:11032<\/code><\/p>\n<p>2b. alternative one-line:<br \/>\n<code>ffmpeg.exe -i input -ar 16k -f s16le - | ssh root@your-cam-ip \/media\/mmcblk0p2\/snx_audio\/snx_audio_playback -d s16 -s 32k -f -<\/code><\/p>\n<p>3. remote mic (disable snx_rtsp_server audio first at \/media\/mmcblk0p2\/data\/etc\/scripts\/20-rtsp-server):<br \/>\n<code># listen port 12016, ready to stream audio data<\/code><br \/>\n<code>tcpsvd 0.0.0.0 12016 \/media\/mmcblk0p2\/snx_audio\/snx_audio_record -d s16 -s 16k -f -<\/code><br \/>\n<code># play on pc<\/code><br \/>\n<code>ffplay -f s16le -ar 16k -ac 1 -nodisp tcp:\/\/your-cam-ip:12016<\/code><\/p>\n<p>3b. alternative one-line:<br \/>\n<code>ssh root@your-cam-ip \/media\/mmcblk0p2\/snx_audio\/snx_audio_record -d s16 -s 16k -f - | ffplay -f s16le -ar 16k -ac 1 -nodisp -<\/code><\/p>\n<p>4. Enable SSH key login (the \/root home directory isn&#8217;t writable so we have to move it):<br \/>\n<code>cp -r \/root \/media\/mmcblk0p2\/<\/code><br \/>\n<code>sed -i 's#\/root#\/media\/mmcblk0p2\/root#g' \/etc\/passwd<\/code><br \/>\n<code>mkdir -p \/media\/mmcblk0p2\/root\/.ssh<\/code><br \/>\n<code>chmod 700 \/media\/mmcblk0p2\/root\/.ssh<\/code><br \/>\n<code>touch \/media\/mmcblk0p2\/root\/.ssh\/authorized_keys<\/code><br \/>\n<code>chmod 600 \/media\/mmcblk0p2\/root\/.ssh\/authorized_keys<\/code><br \/>\n<code>echo 'YOUR_KEY_HERE' &gt;&gt; \/media\/mmcblk0p2\/root\/.ssh\/authorized_keys<\/code><\/p>\n<p>Source:<br \/>\n&#8211; https:\/\/github.com\/samtap\/fang-hacks\/blob\/ca435dd90e1bf290d58d31874be594af34cf21a5\/INSTALL.md<br \/>\n&#8211; https:\/\/github.com\/samtap\/fang-hacks\/issues\/305<br \/>\n&#8211; https:\/\/github.com\/samtap\/fang-hacks\/issues\/310<br \/>\n&#8211; https:\/\/github.com\/EliasKotlyar\/Xiaomi-Dafang-Hacks\/issues\/718<\/p>\n","protected":false},"excerpt":{"rendered":"<p>XiaoFang IP Camera with samtap&#8217;s fang-hacks (https:\/\/github.com\/samtap\/fang-hacks), you can get 2-way audio with a little trick: 1. download necessary files (from https:\/\/github.com\/samtap\/fang-hacks\/issues\/305) and put it on \/media\/mmcblk0p2\/snx_audio (dont forget to set permission execute): &#8211; snx_audio_playback &#8211; snx_audio_record 2. remote speaker: # set gpio gpio_ms1 -n 7 -m 1 -v 1 # listen audio data in &hellip; <a href=\"https:\/\/prosindo.com\/blog\/2020\/04\/16\/two-way-audio-with-xiaofang-hack\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Two Way Audio with XiaoFang Hack&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-206","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/posts\/206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/comments?post=206"}],"version-history":[{"count":4,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/posts\/206\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/posts\/206\/revisions\/210"}],"wp:attachment":[{"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/media?parent=206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/categories?post=206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/tags?post=206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}