I'm doing some research on how to stream multichannel audio from an android device to an external DAC.
The receiver has a USB2-B audio input which I would like to stream audio to from the phone.
It seems that Android OS has limited support for USB Audio - but it's more than nothing for a start. I've also read that some apps in this space use their custom driver...
I went through a lot of questions and answers here (and on other sites) but somehow I can't get a proper answer (most of them are super old or just not exactly what I am aiming for...)
So how can I stream an mp4 file with 4-6 channels of audio through the USB to an external DAC? The file is coded with AAC-LC and/or xHE-AAC - so the file itself supports multichannel. The phone is running Android 11.
I've been looking at the USB-Host mode, and USB Audio website, among several other StackOverflow examples, and also visited extreamsd.com to see how they did it but not much luck with seeing actual code samples...
Anyone could point me in the right direction or whether it is possible at all and if yes then how?
Thank you
Related
I've looked up around for a way to achieve mainly 3 different things with Android:
How to getting listed all the audio output and input devices?
I've found out that there's a method added since API 23 on AudioManager instances according to Android documentation which does this, but there's no documentation about a solution for previous versions. This question remains unanswered here at StackOverflow and several places online.
How to pick up a specific audio output device to stream audio?
The purpose I want to acomplish with this is to select one of the available output devices and stream out the audio by it. Is there a way to do so?
How to record by a specific input device?
The same that before, specific device usage, but in the other way around, I mean, to select one of the available microphones and use it to record audio.
Please help me with some guidence, source code or idea, all of them will be very welcome.
I have been wondering, on how to capture Audio inputs through USB in Android.
My scenario is to receive audio through external hardware and play that received audio through android app. This transmission is to be done over USB.
Is there any way to do this using Android SDK / Android NDK.
Any suggestion will be helpful to me.
Task Done Right by time I am able to interact with Hardware using CDC class and also able to play some random noisy audio through USB in my app. Neither I am able to get clear sound by that approach, nor there is consistency within the transmission of audio.
Thanks.
Regards, Vivek
Most modern Android devices can act as USB host. So you can connect e.g. USB microphone for capturing the audio. Android also contains support for usb_audio class. Use that to get access to the audio on the device.
Since you have already experimented with Communication Device Class (CDC), you are aware of Android's USB host functionality. Now you need to ensure your peripheral has implemented USB audio class (the audio source part) and make your app to use the audio class to obtain the audio. This pretty well explained here, so it does not make sense to copy all the information to this post. If you are already using audio class, that page may explain some of the issues you have (e.g. using wrong format).
USB Audio class specifications can be found at USB.org website. The problem with those is that Audio class is pretty large and Android probably does not support everything.
Many people are asking for this, no one seems to have an answer so I do neither.
How is it possible that some apps serve the function to record the audio output of the android system? Everything I am finding is the very same tutorial on 1432 different sites where you can record MIC input. I don't care about mic input, I want the audio output and just can't imagine how to access it.
If everyone can get me on the right way, I would be so happy.
Seems to be currently there is no way to achieve this.
This is another question related to this : android get device overall audio output in pcm
The closest API available to you for these purposes is Visualizer. Which only captures "partial and low quality audio content".
I imagine direct audio capture functionality is omitted to prevent pro-piracy apps. It may be worth noting that there is a CAPTURE_AUDIO_OUTPUT permission, but it is "Not for use by third-party applications". So if you really do have legitimate apps that are capable of this, as you claim, they are likely system apps. Even if you wrote an app that generated its own musical sequences, for example, you would still have to write your own encoder/decoder to achieve anything close to what you're asking for (and that wouldn't even be considered audio capture at that point.)
To put it bluntly, it's currently impossible without breaking any ToS with Google or your phone provider, and will probably remain so indefinitely.
In Android 10, they have introduced Audio Playback Capture API using which we can capture the Audio being played by other applications. But it's not available in previous android versions.
An app X can also prevent any other app from listening, if that app hasn't added any constraint then this API can be used.
Just Use a bidirectional AUX Cable and hook it in your phone Headphone Port and hook it's another end to your Audio Interface "Line In" Channel (Or Whatever Input You have on your Audio Interface ) and then record that input by audacity or any good Audio Recorder.
TL;DR : use the SCR Screen Recorder app to capture video + internal audio (not microphone) [require root]
Long answer
Original answer: Record tablet's screen AND audio
Jeff's answer seems to be the only way you can use through adb. But that force you to do some work (merge video + audio).
I could do it this way :
- connect the Android device to computer with a jack cable (headphone output to microphone input);
- record video with adb shell;
- record audio with Audacity (or anything else)
- then merge video and audio with a video editor (pitivi, openshot, avconv...)
Another way is to directly use an android app:
SCR Screen Recorder - official website - XDA - short review
Mobizen for SAMSUNG - google play
RecMe - google play
SCR Screen Recorder:
pros :
the only app that truly works for recording video + internal audio with all devices
cons:
banned from google play because of SELinux policy (see XDA - Google Play ban and "Dangerous app" warning)
require root for recording internal audio
Mobizen for SAMSUNG:
pros
on google play store
cons
only the samsung version works for recording internal audio, the general or LG, XIAOMI version can't record internal audio
still a beta feature
require root for recording internal audio
RecMe:
pros
on google play store
cons
internal audio recording doesn't works on most devices
require root for recording internal audio
Personally I tried a lot of apps and the only working for me is SCR Screen Recorder.
PS : all these apps works without root if not using internal audio.
Working on Android 4.0+ above.
I am in process of analyzing ways to live stream my camera video to Window PC using RTP , encoding MPEG-2.
Is there readily available "rtp-server" in android 4.0+ ?
Is following true:: "The Android platform lacks support for
streaming protocol, which makes it difficult to stream live audio /
video to Android enabled devices." extracted from website
Currently I analyzed used the ffserver from the ffmpeg
libraries, but the FPS is < 5. which is far slow. Did any one
explored other solution which has more FPS?
Did anybody tried using StageFright for same? Capturing raw data
from camera and sending it to stagefright framework for encoding and
then streaming the same using RTP ??
Many Thanks.
The answers to your questions are as below. Though the links are related to Android 4.2.2, the same is true for Android 4.0 also.
Yes, there is a RTP transmitter available. You could look at this example in MyTransmitter as a starting point or you can consider using the standard recorder as in startRTPRecording.
You can stream data via RTP from an Android device to an external sink or you could have a different use-case as in Miracast a.k.a. Wi-Fi Display. However, streaming from one android device to another device through Wi-Fi Direct is still not completely enabled. The latter statement is mainly coming from Miracast scenario.
You can use the standard android software, which is capable of high resolution recording and transmission. This is mainly dependent on the underlying hardware as the overhead from software stack is not very high.
Yes. This is already answered in Q1 above.
I have a rooted HiSense GoogleTV which has HDMI IN and OUT ports.
What I want to do is to record about 10 secs of the audio from the HDMI IN (from the set-top box). I am new to this, so please bear with me.
Is this possible to do this on a rooted device?
Does the HDMI data get decrypted (due to HDCP) after the HDMI IN and re-encrypted before it is routed out via HDMI out?
If I were to try to capture the audio frames on a regular Linux box, how should I go about it? What components should I look into? I cannot find any documentation that describes the low level architecture and details on how the HDMI IN signal gets routed to HDMI OUT.
Can you please point to the Android framework code that actually does this routing from HDMI In to OUT? Basically, want to understand the flow of what happens to the audio signal during the transfer from the HDMI IN to the OUT.
I am not sure if my questions make sense, but I hope you can give me some pointers on where I should start.
Short answer: Not possible. The pass-through is completely isolated from android via the Trusted Video Path SOCs. You need to be a certified SOC provider to get anywhere near the signal.
A HDMI input device should be identified as AUDIO_DEVICE_IN_AUX_DIGITAL (see audio.h), though I've never come across an Android device with HDMI input so I can't verify that.
Audio routing is handled by the AudioPolicyManager. There's an AudioPolicyManagerBase in libhardware_legacy, and then there's typically a platform-specific AudioPolicyManager implementation which overloads some of the base class' methods. Where this implementation is found depends on the platform. On Qualcomm platforms it's usually found somewhere under hardware/qcom/audio in the source tree.
The AudioPolicyManager performs high-level routing (like mapping stream types and audio sources to audio devices), and then uses the AudioHardware implementation and possibly other platform-specific classes to do the low-level routing (manage audio streams at the hardware level, load acoustic tuning parameters, interface with device drivers, etc).
Any HDMI input-related functionality is likely to be vendor specific, so might need the full source code for your Google TV device (i.e. including all patches that the vendor has applied on top of vanilla Android) if you want to be able to look at the code that handles HDMI audio input.
You will not be able to access either the video or audio input since Google TV implements HDCP. The only way to change that, even on a rooted device, is to change the Google TV code and probably also the SOC HDMI drivers, neither of which have been open sourced by Google.