Comments (7)
hey @mekwall , maybe try this change? 39bd8c7
I don't like this solution becuase it adds a lot of distortion to the audio sometimes
from sndcpy.
Instead of having VLC as a peer dependency you could distribute this package with a slimmed down version of ffplay and use the following command to play the audio:
$ ffplay -autoexit -nodisp -probesize 32 -f s16le -ar 48k -ac 2 -sync ext tcp://localhost:28200
Latency is still pretty bad, but better than VLC at least.
@mekwall could you show how the batch file works with this updated change?
from sndcpy.
Instead of having VLC as a peer dependency you could distribute this package with a slimmed down version of ffplay and use the following command to play the audio:
$ ffplay -autoexit -nodisp -probesize 32 -f s16le -ar 48k -ac 2 -sync ext tcp://localhost:28200
Latency is still pretty bad, but better than VLC at least.
@mekwall could you show how the batch file works with this updated change?
My solution (I'm still a batch file noob, don't roast me)
Add this at the top:
if not defined FFPLAY set FFPLAY=ffplay.exe
and comment out the vlc line, then add this to replace it:
%FFPLAY% -autoexit -nodisp -probesize 32 -f s16le -ar 48k -ac 2 -sync ext tcp://localhost:%SNDCPY_PORT%
I'm still tweaking it, but the latency got alot better now.
from sndcpy.
Does this fix the buffer delay that keeps increasing as time goes?
from sndcpy.
the ffplay line works forme; can't figure out how to record though.
this doesn't work (in sndcpy script)
ffmpeg -y -probesize 32 -f s16le -ar 48k -ac 2 -i tcp://localhost:28200 out.ogg
from sndcpy.
Instead of having VLC as a peer dependency you could distribute this package with a slimmed down version of ffplay and use the following command to play the audio:
$ ffplay -autoexit -nodisp -probesize 32 -f s16le -ar 48k -ac 2 -sync ext tcp://localhost:28200
Latency is still pretty bad, but better than VLC at least.
@mekwall could you show how the batch file works with this updated change?
I switched from VLC to FFplay and it works great (Latency around 50-300ms)
It's much better than VLC
ffplay -f s16le -probesize 32 -ar 48000 -ac 2 -fflags nobuffer tcp://localhost:28200 -autoexit -nodisp
-fflags nobuffer | removes buffering
Also in SCRCPY I set the delay to 200ms
And now it's almost perfectly in sync
You also need to install the ffmpeg library for this to work.
Here is the batch file code that you can use
`@echo off
if not defined ADB set ADB=adb
if not defined SNDCPY_APK set SNDCPY_APK=sndcpy.apk
if not defined SNDCPY_PORT set SNDCPY_PORT=28200
if not "%1"=="" (
set serial=-s %1
echo Waiting for device %1...
) else (
echo Waiting for device
)
%ADB% %serial% wait-for-device || goto :error
%ADB% %serial% install -t -r -g %SNDCPY_APK% || (
echo Uninstalling existing version first
%ADB% %serial% uninstall com.rom1v.sndcpy || goto :error
%ADB% %serial% install -t -g %SNDCPY_APK% || goto :error
)
%ADB% %serial% shell appops set com.rom1v.sndcpy PROJECT_MEDIA allow
%ADB% %serial% forward tcp:%SNDCPY_PORT% localabstract:sndcpy || goto :error
%ADB% %serial% shell am start com.rom1v.sndcpy/.MainActivity || goto :error
timeout 4
echo Playing audio.
ffplay -f s16le -probesize 32 -ar 48000 -ac 2 -fflags nobuffer tcp://localhost:28200 -autoexit -nodisp
goto :EOF
:error
echo Failed with error #%errorlevel%.
pause
exit /b %errorlevel%`
from sndcpy.
最近也在测试这段代码,正准备回复,发现已经有楼上的答案了。
实际上,如果加上-fflags nobuffer,不用-probesize 32也很流畅,几乎是正常感知的速度了,玩乒乓球时,我看到投屏的画面对方击发球了,心里预期听到声音时,声音就发出来了。
ffplay -hide_banner -fflags nobuffer -f s16le -ar 48k -ac 2 -sync ext -autoexit -nodisp -i tcp://localhost:%SNDCPY_PORT%
另:如多次开关音频投放,在创建端口转发前先关闭已建立的转发端口似乎成功率会大些。
%ADB% %serial% forward --remove-all
%ADB% %serial% forward tcp:%SNDCPY_PORT% localabstract:sndcpy || goto :error
from sndcpy.
Related Issues (20)
- apk and vlc has running ,but no sound HOT 1
- Change application id if not allowed to be installed on some devices for security issue. HOT 1
- Problem Parsing the Package
- Looks like sndcpy doesn't work with apps that have In-call volume function inside it. HOT 7
- is it possible to to passed microphone from the Host / Mac to Android ?
- 'C:\Program' is not recognized as an internal or external command
- Newbie Problems
- Phone tell
- audio forwarding is not working HOT 1
- miccpy? HOT 1
- How do i make a silent start for sndcpy?, (Not showing the console) HOT 1
- adb: failed to install sndcpy.apk: Security exception: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag HOT 2
- Waiting for device... HOT 2
- SNDCPY, adb: failed to stat sndcpy.apk: No such file or directory HOT 2
- can i ask something HOT 1
- Audio not working for android 10 HOT 4
- sndcpy does not transfer audio played by poweramp
- Got this issue with sndcpy. Also the app doesn't show up after being installed.
- Issue with Sndcpy, HOT 3
- Audio delay using sndcpy HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sndcpy.