rom1v / sndcpy

Android audio forwarding (scrcpy, but for audio)
MIT License
3.25k stars 297 forks source link

vlc can not run #1

Open tz527129804 opened 4 years ago

tz527129804 commented 4 years ago

I’m using huawei‘s EMUI 10.1 and Notification bar shows forwarding (Microphone permission has been given).But nothing happened after “playing audio” has occurred.

I have changed the vlc to the correct path on my win10 without changing other configs. Mybe I need to install VLC to the default path ?

slimsymphony commented 4 years ago

yep, install vlc on your pc then work like charm~

rom1v commented 4 years ago

Mybe I need to install VLC to the default path ?

Yes, or you can set an environment variable containing the full path to vlc.exe: https://github.com/rom1v/sndcpy/blob/master/README.md#environment-variables

Default value is C:\Program Files\VideoLAN\VLC\vlc.exe:

https://github.com/rom1v/sndcpy/blob/dd76c6f4384564ee11151200751e07898cdf67d6/sndcpy.bat#L3

tz527129804 commented 4 years ago

Mybe I need to install VLC to the default path ?

Yes, or you can set an environment variable containing the full path to vlc.exe: https://github.com/rom1v/sndcpy/blob/master/README.md#environment-variables

Default value is C:\Program Files\VideoLAN\VLC\vlc.exe:

https://github.com/rom1v/sndcpy/blob/dd76c6f4384564ee11151200751e07898cdf67d6/sndcpy.bat#L3

I try again,reinstall VLC to default path(C:\Program Files\VideoLAN\VLC\vlc.exe). then I run the sndcpy.bat Here is the display content:

Waiting for device...
Performing Streamed Install
Success
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.rom1v.sndcpy/.MainActivity }
Press Enter once audio capture is authorized on the device to start playing...
Playing audio...

I still can’t see VLC playing anything 😭 To be precise, vlc even did not appear!

rom1v commented 4 years ago

To be precise, vlc even did not appear!

That's expected, it is started with -Idummy.

https://github.com/rom1v/sndcpy/blob/dd76c6f4384564ee11151200751e07898cdf67d6/sndcpy.bat#L25

But the audio should still be played.

tz527129804 commented 4 years ago

To be precise, vlc even did not appear!

That's expected, it is started with -Idummy. But the audio should still be played.

https://github.com/rom1v/sndcpy/blob/dd76c6f4384564ee11151200751e07898cdf67d6/sndcpy.bat#L25

I can see TCP link established,but no audio played,maybe huawei‘s EMUI changes some system settings. (Ps : miracast protocol can transfer audio with low delay.I have used it on win10 as an alternative) Thank you for your answer !

rom1v commented 4 years ago

I can see TCP link established,but no audio played

What application do you test? Some apps do not allow to capture their audio (this unfortunately includes Firefox and Chrome).

For example, try youtube or VLC for Android.

tz527129804 commented 4 years ago

Unfortunately,still no sound

I can see TCP link established,but no audio played

What application do you test? Some apps do not allow to capture their audio (this unfortunately includes Firefox and Chrome).

For example, try youtube or VLC for Android.

Unfortunately,still no sound. l will try another phone in the future.

rom1v commented 4 years ago

Try to remove -Idummy for there:

https://github.com/rom1v/sndcpy/blob/dd76c6f4384564ee11151200751e07898cdf67d6/sndcpy.bat#L25

As a consequence, it will open the VLC gui. Maybe it will give a hint about the problem. For example, press Ctrl+m in the VLC window to open the messages dialog.

tz527129804 commented 4 years ago

Try to remove -Idummy for there:

https://github.com/rom1v/sndcpy/blob/dd76c6f4384564ee11151200751e07898cdf67d6/sndcpy.bat#L25

As a consequence, it will open the VLC gui. Maybe it will give a hint about the problem. For example, press Ctrl+m in the VLC window to open the messages dialog.

I can see VLC and timeline moving forward now,but no sound out from PC . Ctrl+m No message log (whatever the detail level),but many thing can be seen in Module tree

SarthakAnil commented 4 years ago

main stream error: connection error: Connection refused this is the error i get when i run ./sndcpy on my manjaro any idea what is happening tried removing -Idummy,can see VLC and timeline moving forward now,but no sound out from PC . Ctrl+m No message log sound still coming from device

rom1v commented 4 years ago

main stream error: connection error: Connection refused

I you get it once, it's expected (cf README).

but no sound out from PC

OK, so it seems several people have this problem.

Could you please build with these changes and run:

diff --git a/app/src/main/java/com/rom1v/sndcpy/RecordService.java b/app/src/main/java/com/rom1v/sndcpy/RecordService.java
index 8486332..f867724 100644
--- a/app/src/main/java/com/rom1v/sndcpy/RecordService.java
+++ b/app/src/main/java/com/rom1v/sndcpy/RecordService.java
@@ -155,6 +155,23 @@ public class RecordService extends Service {
         return builder.build();
     }

+    public static String buildPacketString(byte[] data, int offset, int len) {
+        int limit = Math.min(20, len);
+        StringBuilder builder = new StringBuilder();
+        builder.append('[').append(len).append(" bytes] ");
+        for (int i = 0; i < limit; ++i) {
+            if (i != 0) {
+                String sep = i % 4 == 0 ? "  " : " ";
+                builder.append(sep);
+            }
+            builder.append(String.format("%02X", data[offset + i] & 0xff));
+        }
+        if (limit < len) {
+            builder.append("  ... +").append(len - limit).append(" bytes");
+        }
+        return builder.toString();
+    }
+
     private void startRecording() {
         final AudioRecord recorder = createAudioRecord(mediaProjection);

@@ -169,6 +186,7 @@ public class RecordService extends Service {
                     byte[] buf = new byte[SAMPLE_RATE * CHANNELS * BUFFER_MS / 1000];
                     while (true) {
                         int r = recorder.read(buf, 0, buf.length);
+                        Log.i(TAG, buildPacketString(buf, 0, buf.length));
                         socket.getOutputStream().write(buf, 0, r);
                     }
                 } catch (IOException e) {

Then look at the output of adb logcat -s sndcpy.

tz527129804 commented 4 years ago

main stream error: connection error: Connection refused

I you get it once, it's expected (cf README).

but no sound out from PC

OK, so it seems several people have this problem.

Could you please build with these changes and run:

diff --git a/app/src/main/java/com/rom1v/sndcpy/RecordService.java b/app/src/main/java/com/rom1v/sndcpy/RecordService.java
index 8486332..f867724 100644
--- a/app/src/main/java/com/rom1v/sndcpy/RecordService.java
+++ b/app/src/main/java/com/rom1v/sndcpy/RecordService.java
@@ -155,6 +155,23 @@ public class RecordService extends Service {
         return builder.build();
     }

+    public static String buildPacketString(byte[] data, int offset, int len) {
+        int limit = Math.min(20, len);
+        StringBuilder builder = new StringBuilder();
+        builder.append('[').append(len).append(" bytes] ");
+        for (int i = 0; i < limit; ++i) {
+            if (i != 0) {
+                String sep = i % 4 == 0 ? "  " : " ";
+                builder.append(sep);
+            }
+            builder.append(String.format("%02X", data[offset + i] & 0xff));
+        }
+        if (limit < len) {
+            builder.append("  ... +").append(len - limit).append(" bytes");
+        }
+        return builder.toString();
+    }
+
     private void startRecording() {
         final AudioRecord recorder = createAudioRecord(mediaProjection);

@@ -169,6 +186,7 @@ public class RecordService extends Service {
                     byte[] buf = new byte[SAMPLE_RATE * CHANNELS * BUFFER_MS / 1000];
                     while (true) {
                         int r = recorder.read(buf, 0, buf.length);
+                        Log.i(TAG, buildPacketString(buf, 0, buf.length));
                         socket.getOutputStream().write(buf, 0, r);
                     }
                 } catch (IOException e) {

Then look at the output of adb logcat -s sndcpy.

sorry,I'm not a programmer,so I don’t konw which file to change, and how to build....

tz527129804 commented 4 years ago

Then look at the output of adb logcat -s sndcpy.

I did it with google ! here is the log:

$ adb logcat -s sndcpy
--------- beginning of crash
--------- beginning of system
--------- beginning of main
06-11 13:05:48.120 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.164 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.183 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.186 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.205 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.312 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.313 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.332 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.486 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.504 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.614 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.633 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.761 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.780 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.868 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.889 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.891 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.891 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:48.908 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:49.018 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes
06-11 13:05:49.037 30633 1942 I sndcpy : [1440 bytes] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... +1420 bytes

Keep repeating until I close the server.

rom1v commented 4 years ago

OK, so the Playback Capture API on your device does not capture the app sound. What app did you use when you captured these logs?

tz527129804 commented 4 years ago

OK, so the Playback Capture API on your device does not capture the app sound. What app did you use when you captured these logs?

Oh!I just test again. The yandex browser for android can play sound on PC. youtube can play! But Huawei's own browser can't.(Like the log above) VLC for android can't.(Like the log above) Wechat can't.(Like the log above)

I think the problem may be related to Huawei system.

tz527129804 commented 4 years ago

OK, so the Playback Capture API on your device does not capture the app sound. What app did you use when you captured these logs?

I think huawei provides different api,and I just use youtube which can work. Maybe you can test what differences between these apps. Good luck.😀

1235467 commented 1 year ago

Sound forwarding of Youtube Music and Youtube did work in my case.Testing on EMUI 10.1,a Huawei device.But Poweramp is not working.