Git Product home page Git Product logo

Comments (14)

trykert avatar trykert commented on June 4, 2024 1

To replace VLC with mpv or ffplay, I tried using the following line replacements (for the line bellow "echo Playing audio..."). They seem to work well. In fact, I get very little delay with ffplay and both processes terminate on Windows after closing the script.

For mpv:

mpv --demuxer=rawaudio --demuxer-rawaudio-rate=48000 --no-cache --untimed --no-demuxer-thread --demuxer-cache-wait=no --no-terminal tcp://localhost:%SNDCPY_PORT%

For ffplay:

ffplay -hide_banner -loglevel fatal -nodisp -f s16le -probesize 32 -ac 2 -ar 48000 -acodec pcm_s16le tcp://localhost:%SNDCPY_PORT%

mpv uses the wrong sample rate. It should be 48 KHz as shown in VLC, but mpv always uses 44.1 KHz.

I added the flag --demuxer-rawaudio-rate=48000, so that's fixed.

I was trying to do that as well, as I was sure that mpv wouldn't have delay (evidenced by other times I used mpv vs VLC).
Your parameters worked great, thank you!

One thing for me (on Windows 10, mpv-x86_64-20220703-git-369168b), is that --no-terminal didn't stop an OSC screen appearing for MPV, so I deleted that and used --player-operation-mode=cplayer instead:

mpv --demuxer=rawaudio --demuxer-rawaudio-rate=48000 --no-cache --untimed --no-demuxer-thread --demuxer-cache-wait=no --player-operation-mode=cplayer tcp://localhost:%SNDCPY_PORT%

from sndcpy.

rom1v avatar rom1v commented on June 4, 2024

Probably, or even aplay from ffmpeg.

But it's just a PoC, so I probably won't add options to select another player. You could just edit the last line of sndcpy to call mpv with the right parameters.

from sndcpy.

sharunkumar avatar sharunkumar commented on June 4, 2024

hm got it. I put together this script after looking up the manual

@echo off
adb shell am start com.rom1v.sndcpy/.MainActivity
pause
mpv tcp://localhost:28200 --demuxer=rawaudio --no-cache --demuxer-cache-wait=no

but still there is some latency in the audio. is this unavoidable?

from sndcpy.

rom1v avatar rom1v commented on June 4, 2024

Over USB or Wifi?

Do you get the same latency with VLC?

from sndcpy.

sharunkumar avatar sharunkumar commented on June 4, 2024

Over USB.

Latency is there in VLC but not as much as experienced on MPV

from sndcpy.

rom1v avatar rom1v commented on June 4, 2024

With VLC, do you see such lines in the console: https://github.com/rom1v/sndcpy/blob/master/README.md#audio-delay ?

If not, over USB, you could try to change --network-cache=50 (milliseconds) to a smaller value.

from sndcpy.

sharunkumar avatar sharunkumar commented on June 4, 2024

If not, over USB, you could try to change --network-cache=50 (milliseconds) to a smaller value.

setting it to 0 has helped with reducing the latency. though I'm not sure how to set a similar setting in mpv. will have to look around.

on a related note, how do I close vlc when it is playing in the background?

from sndcpy.

sharunkumar avatar sharunkumar commented on June 4, 2024

Okay, one more thing. When I play youtube, the audio forwards. But not when playing from an audio only source like spotify. is this intentional? 🤔

from sndcpy.

rom1v avatar rom1v commented on June 4, 2024

setting it to 0 has helped with reducing the latency. though I'm not sure how to set a similar setting in mpv. will have to look around.

OK, I think I will change it to 0 by default then.

on a related note, how do I close vlc when it is playing in the background?

Because it's Windows and it's "console" vs "non-console" mode is stupid.

Once you clicked on START NOW, press Enter in the console to start playing on the computer. Press Ctrl+c in the terminal to stop (except on Windows, just disconnect the device or stop capture from the device notifications).

https://github.com/rom1v/sndcpy/blob/master/README.md

But not when playing from an audio only source like spotify. is this intentional?

https://github.com/rom1v/sndcpy/blob/master/README.md#apps-restrictions

from sndcpy.

sharunkumar avatar sharunkumar commented on June 4, 2024

Damn sorry should have read the docs fully 😅

from sndcpy.

PieFlavours avatar PieFlavours commented on June 4, 2024

Im trying to edit the file to use mpv instead of vlc but it's not working. Could i get step-by-step instructions to help out?

from sndcpy.

DarkXonline avatar DarkXonline commented on June 4, 2024

Im trying to edit the file to use mpv instead of vlc but it's not working. Could i get step-by-step instructions to help out?

download and extract mpv and put inside mpv folder
Copy paste this code to .bat file and run:

@echo off
if not defined ADB set ADB=adb
if not defined mpv set mpv="mpv\mpv"
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% forward tcp:%SNDCPY_PORT% localabstract:sndcpy || goto :error
%ADB% %serial% shell am start com.rom1v.sndcpy/.MainActivity || goto :error
echo Press Enter once audio capture is authorized on the device to start playing...
pause >nul
echo Playing audio...
%mpv% tcp://localhost:%SNDCPY_PORT% --demuxer=rawaudio --no-cache --demuxer-cache-wait=no
goto :EOF

:error
echo Failed with error #%errorlevel%.
pause
exit /b %errorlevel%

from sndcpy.

Tatsh avatar Tatsh commented on June 4, 2024

mpv uses the wrong sample rate. It should be 48 KHz as shown in VLC, but mpv always uses 44.1 KHz.

from sndcpy.

rafuwu avatar rafuwu commented on June 4, 2024

To replace VLC with mpv or ffplay, I tried using the following line replacements (for the line bellow "echo Playing audio...").
They seem to work well. In fact, I get very little delay with ffplay and both processes terminate on Windows after closing the script.

For mpv:

mpv --demuxer=rawaudio --demuxer-rawaudio-rate=48000 --no-cache --untimed --no-demuxer-thread --demuxer-cache-wait=no --no-terminal tcp://localhost:%SNDCPY_PORT%

For ffplay:

ffplay -hide_banner -loglevel fatal -nodisp -f s16le -probesize 32 -ac 2 -ar 48000 -acodec pcm_s16le tcp://localhost:%SNDCPY_PORT%

mpv uses the wrong sample rate. It should be 48 KHz as shown in VLC, but mpv always uses 44.1 KHz.

I added the flag --demuxer-rawaudio-rate=48000, so that's fixed.

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.