Giter Site home page Giter Site logo

Use ffplay instead of VLC about sndcpy HOT 7 OPEN

rom1v avatar rom1v commented on May 22, 2024 7
Use ffplay instead of VLC

from sndcpy.

Comments (7)

FerLuisxd avatar FerLuisxd commented on May 22, 2024

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.

evansmosomi avatar evansmosomi commented on May 22, 2024

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.

johnchen40904 avatar johnchen40904 commented on May 22, 2024

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.

R-N avatar R-N commented on May 22, 2024

Does this fix the buffer delay that keeps increasing as time goes?

from sndcpy.

clort81 avatar clort81 commented on May 22, 2024

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.

ziengri avatar ziengri commented on May 22, 2024

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.

wglnngt avatar wglnngt commented on May 22, 2024

最近也在测试这段代码,正准备回复,发现已经有楼上的答案了。
实际上,如果加上-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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.