Audio volume control using the mergExt mergAV external - audio

How do I control the audio volume of an A/V player created by the LiveCode mergExt suite's mergAV external? I need to turn the player's audio on and off, as well as set its volume to a specific value (0 - 100).

It's not currently possible so would need to be added to mergAV. Unfortunately Apple decided not to give AVPlayer an volume or mute property which is why it's not yet implemented. There is a workaround though. There is also MPVolumeView which could be added to mergMP which presents the system volume control.

Related

Sending a webcam input to zoom using a recorded clip

I have an idea that I have been working on, but there are some technical details that I would love to understand before I proceed.
From what I understand, Linux communicates with the underlying hardware through the /dev/. I was messing around with my video cam input to zoom and I found someone explaining that I need to create a virtual device and mount it to the output of another program called v4loop.
My questions are
1- How does Zoom detect the webcams available for input. My /dev directory has 2 "files" called video (/dev/video0 and /dev/video1), yet zoom only detects one webcam. Is the webcam communication done through this video file or not? If yes, why does simply creating one doesn't affect Zoom input choices. If not, how does zoom detect the input and read the webcam feed?
2- can I create a virtual device and write a kernel module for it that feeds the input from a local file. I have written a lot of kernel modules, and I know they have a read, write, release methods. I want to parse the video whenever a read request from zoom is issued. How should the video be encoded? Is it an mp4 or a raw format or something else? How fast should I be sending input (in terms of kilobytes). I think it is a function of my webcam recording specs. If it is 1920x1080, and each pixel is 3 bytes (RGB), and it is recording at 20 fps, I can simply calculate how many bytes are generated per second, but how does Zoom expect the input to be Fed into it. Assuming that it is sending the strean in real time, then it should be reading input every few milliseconds. How do I get access to such information?
Thank you in advance. This is a learning experiment, I am just trying to do something fun that I am motivated to do, while learning more about Linux-hardware communication. I am still a beginner, so please go easy on me.
Apparently, there are two types of /dev/video* files. One for the metadata and the other is for the actual stream from the webcam. Creating a virtual device of the same type as the stream in the /dev directory did result in Zoom recognizing it as an independent webcam, even without creating its metadata file. I did finally achieve what I wanted, but I used OBS Studio virtual camera feature that was added after update 26.0.1, and it is working perfectly so far.

How do you automatically detect device dimensions when using HTTP Live Streaming?

I have an app that delivers video content using HTTP Live Streaming. I want the app to retrieve the appropriate resolution based on the devices screen size (either 4x3 or 16x9). I ran Apple's tool to create the master .m3u8 playlist file (variantplaylistcreator) and got the following:
#EXTM3U
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=248842,BANDWIDTH=394849,CODECS="mp4a.40.2, avc1.4d4028",RESOLUTION=480x360
4x3/lo/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=384278,BANDWIDTH=926092,CODECS="mp4a.40.2, avc1.4d4028",RESOLUTION=480x360
4x3/mid/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=787643,BANDWIDTH=985991,CODECS="mp4a.40.2, avc1.42801e",RESOLUTION=480x360
4x3/hi/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=249335,BANDWIDTH=392133,CODECS="mp4a.40.2, avc1.4d4028",RESOLUTION=640x360
16x9/lo/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=384399,BANDWIDTH=950686,CODECS="mp4a.40.2, avc1.4d4028",RESOLUTION=640x360
16x9/mid/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=780648,BANDWIDTH=987197,CODECS="mp4a.40.2, avc1.42801e",RESOLUTION=640x360
16x9/hi/prog_index.m3u8
This does cause my live stream to switch between video quality correctly, but it seems to randomly pick whether it uses a 4x3 or 16x9 resolution.
Is there a way to have it select the correct dimensions automatically, or do I need to have multiple playlist files and have a device request a specific one? For example, if on an iPad do I need to detect that it's screen has a 4x3 dimension and request a 4x3_playlist.m3u8 that only has the 480x360 resolution option?
Update 2017:
Keeping the same aspect-ratio is only a recommendation in the latest HLS authoring guide:
1.33. All video variants SHOULD have identical aspect ratios.
Original answer:
Audio/Video Stream Considerations:
Video aspect ratio must be exactly
the same, but can be different dimensions.
Apple Technical Note TN2224 - Best Practices for Creating and Deploying HTTP Live Streaming Media for the iPhone and iPad
Select a playlist based on the User-Agent instead.

Corona SDK - Can you change the device's volume setting or at least get the device's volume setting

Corona SDK has apis like audio.setVolume and audio.setMaxVolume and audio.getVolume
But it seems as though these do nothing more than change the maximum volume in the Corona environment or get the volume in the corona environment.
My app lets you record your voice and play it back. When users can't hear themselves, they complain and blame my app.
I've found that in most cases ( possibly all, but I can't verify ), users tell me the volume was somehow set to off but they didn't realize it. And for some reason they don't check the volume first before wondering why they hear no sound.
If I could show the user what the device's volume is, this would solve the problem. And if I could give them a slider to update the volume for the device, even better for users who are confused by how to change volume through the device.
Apparently, it is not possible to get the device volume at this time using Corona.
This seems to work for iOS but not Android... check out the following link: http://developer.coronalabs.com/forum/2011/06/05/new-audiosession-properties
if audio.supportsSessionProperty then
local master_ringer_volume = audio.getSessionProperty(1667788662)
if (master_ringer_volume ~= nil) then
if (master_ringer_volume < 0.25) then
-- Do whatever you need to here...
end
end
end

I hear clicking in audio with a DirectShow graph created with Graph Edit yet player software on my PC plays audio smoothly

I have a DirectShow application that I built with Delphi 6 using the DSPACK component library. For two days I have been trying to solve a problem with audio playback. When I run the filter graph I create I hear repetitive clicks in the playback. What was really confusing was that the audio file I created simultaneously with my filter graph had clean continuous audio, not gaps. So I knew that the audio buffers were being delivered properly but something I was doing was "jamming up" the "live" playback. Or so I thought. I spent two days diagnosing the problem looking for semaphores being held too long (locks) or perhaps timestamp problems, which I documented in this other Stack Overflow post:
Getting stuttering during rendering of my DirectShow filter despite output file being "smooth"
A few minutes ago I decided to try a test with the Graph Edit utility. I created a dead simple graph consisting of just the capture device I was using (VOIP phone microphone), and the renderer device I was using (HD ATI Rear Audio output to headphones). Two filters total. Much to my surprise I heard the same clicking. So here was a case that did not involve my code at all and I heard clicking.
Then I changed the audio renderer in the Graph Edit created filter graph to the VOIP phone ear piece. The clicking went away.
Now I know there's a way to get smooth audio on ut the ATI Rear Audio device since its the preferred audio output device and everything from videos I play on my PC to wave files I play on it sound flawless. So are the other software programs doing something different than just connecting filters? I am wondering if perhaps the default mode for the HD ATI Rear Audio is without double-buffering and perhaps those other software programs know how to enable that feature? Or are they doing something else, perhaps using another DirectShow or DirectSound filter or technique for example, to make the audio play smoothly on the HD ATI Rear Audio renderer?
What you possibly having (depends on actual stuttering though) is that when you are using capture and playback devices backed by different hardware, their sampling rates slightly differ. For example, you capture 22050 Hz at actual rate of (22050 - 2%) Hz and you play it back with hardware consuming bytes at (22050 + 2%) Hz.
Now obviously this won't work out smooth: eventually playback will experience data underlow... If you save into file and play back from file, it will go smooth as the file will be able to supply data at the rate of playback device. If capture and playback devices are the same hardware, they are likely to use shared "hardware" clock and rates match.
The problem is known as "rate matcing" and is discussed on MSDN in Live Sources section.

Can v4l2 be used to read audio and video from the same device?

I have a capture card that captures SDI video with embedded audio. I have source code for a Linux driver, which I am trying to enhance to add video4linux2 support. My changes are based on the vivi example.
The problem I've come up against is that all the example I can find deal with only video or only audio. Even on the client side, everything seems to assume v4l is just video, like ffmpeg's libavdevice.
Do I need to have my driver create two separate devices, a v4l2 device and an alsa device? It seems like this makes the job of keeping audio and video in sync much more difficult.
I would prefer some way for each buffer passed between the driver and the app (through v4l2's mmap interface) contain a frame, plus some audio that matches up (with respect to time) with that frame.
Or perhaps have each buffer contain a flag indicating if it is a video frame, or a chunk of audio. Then the time stamps on the buffers could be used to sync things up.
But I don't see a way to do this with the V4L2 API spec, nor do I see any examples of v4l2-enabled apps (gstreamer, ffmpeg, transcode, etc) reading both audio and video from a single device.
Generally, the audio capture part of a device shows up as a separate device. It's usually a different physical device (posibly sharing a card), which makes sense. I'm not sure how much help that is, but it's how all of the software I'm familiar with works...
There are some spare or reserved fields in the v4l2 buffers that can be used to pass audio or other data from the driver to the calling application via pointers to mmaped buffers.
I modified the BT8x8 driver to use this approach to pass data from an A/D card synchronized to the video on Ubuntu 6.06.
It worked OK, but the effort of maintaining my modified driver caused me to abandon this approach.
If you are still interested I could dig out the details.
IF you want your driver to play with gstreamer etc. a separate audio device generally is what is expected.
Most of the cheap v4l2 capture card's audio is only an analog pass through with a volume control requiring a jumper to capture the audio via the sound card's line input.

Resources