AVPlayer Add Delay to Audio but Not Video (Swift) - swift

I have an HLS live stream (from an external source, not one I created or can edit) with video and several audio options. I can successfully change the audio to one of the alternatives, but the alternative audio the stream provides doesn't match up perfectly with with video (it's about 1.5 seconds ahead of the video).
Is there a way to have the AVPlayer delay the audio portion of the stream by some specified amount to correct for this? Or is that not possible?

Related

Record Audio from an in app video in Ionic

I have some videos coming from an API's response. I need a button to start recording the audio from the selected video for 30 seconds and get the file version of that audio to use it further.
I am already using this.audio.startRecord(); from Media Plugin but that records outside audio from phone's mic. It also stops the video that is playing on its own.

Play two audio sources during a live video stream

I'm working with the Azure Media Player( https://ampdemo.azureedge.net/ ). I need a second audio source (which will be music) to be overlaid on top of the video with presenter talking. I see there's the ability to select multiple audio streams if the video is stored on Azure. (English/spanish/etc...) However, in my case it will be video and presenter(talking) on the video live stream and I'd like to be able to select a music stream of the viewers choice during the live stream which will be stored music in Azure.
Is this possible?
Then take it to the next step, does the player provide the capability of setting the volume on each stream? If not, is the player extendable?
Azure Media Player(AMP) doesn't allow playing multiple audio streams at the same time. You could achieve your desired behavior by including a hidden HTML5 video player and use that to play your additional audio. You'll probably want to use javascript to "synchronize" the hidden video player with Azure Media Player, i.e. When AMP plays, you play the hidden video player. When AMP pauses, you pause the hidden video player.

How to play video while it is downloading using AVPro video in unity3D?

I want to play the video simultaneously while it is downloading via unitywebrequest. Will AVPro video support this? If so please provide me some guidance, as i am new to unity and avpro video. I can able to play the video which is downloaded fully through FullscreenVideo.prefab in AVPro demo. Any help will be much appreciated.
There are two main options you could use for displaying the video while it is still downloading.
Through livestream
You can stream a video to AVPro video using the "absolute path or URL" option on the media player component, then linking this to a stream in rtsp, MPEG-DASH, HLS, or HTTP progressive streaming format. Depending on what platforms you will be targeting some of these options will work better than others
A table of which file format supports what platform can be found in the AVProVideo Usermanual that is included with AVProVideo from page 12 and onwards.
If you want to use streaming you also need to set the "internet access" option to "required" in the player settings, as a video cannot stream without internet access.
A video that is being streamed will automatically start/resume playing when enough video is buffered.
This does however require a constant internet connection which may not be ideal if you're targeting mobile devices, or unnecessary if you're planning to play videos in a loop.
HLS m3u8
HTTP Live Streaming (HLS) works by cutting the overall stream into shorter, manageable hunks of data. These chunks will then get downloaded in sequence regardless of how long the stream is. m3u8 is a file format that works with playlists that keeps information on the location of multiple media files instead of an entire video, this can then be fed into a HLS player that will play the small media files in sequence as dictated in the m3u8 file.
using this method is usefull if you're planning to play smaller videos on repeat as the user will only have to download each chunk of the video once, which you can then store for later use.
You can also make these chunks of video as long or short as you want, and set a buffer of how many chunks you want to have pre-loaded. if for example you set the chunk size to 5 seconds, with a buffer of 5 videos the only loading time you'll have is when loading the first 25 seconds of the video. once these first 5 chunks are loaded it will start playing the video and load the rest of the chunks in the background, without interrupting the video (given your internet speed can handle it)
a con to this would be that you have to convert all your videos to m3u8 yourself. a tool such as FFMPEG can help with this though.
references
HLS
m3u8
AVPro documentation

Recording audio output only from speaker of iphone excluding microphone

I am trying to record the sound from iPhone speaker. I am able to do that, but I am unable to avoid mic input in the recorded output. Tried with sample code available in different websites with no luck.
The sample which I used does the recording with audio units. I need to know if there is any property for audio unit to set the mic input volume to zero. Above that I came to from other posts that Audio Queue services can do the thing for me. Can any one redirect me with sample code for the audio queue services implementation. I need to know whether there is a way of writing the data to an separate audio file before sending it as input to speaker.
Thanks in advance
There is no public iOS API or property for recording generic audio sent to the iPhone speaker. Only mic input can be recorded.
But if you are playing audio in your app using only uncompressed samples with Audio Queues or the RemoteIO Audio Unit, you can just copy those samples to a file before you write them to the audio callback buffers. Those saved samples can be used to construct a recording.

Recording Radio Streaming in IOS

I am working on radio app in which i want to record live radio streaming on an record button click.It should record just the radio streaming sound. Currently i am recording from Mike but its not the way i want as it also captures the surrounding/background voice. I did read few post but all of them are regarding AVaudioRecorder. I have used wunderradio api for playing the radio from url. I haven't got any method/function in their api which will record that audio from url. I want to record the buffered audio only from that url,so that I can play that recorded file later.
Any help would be appreciated.
Recording audio playback by using the microphone is really not the right way to do it. If you're using AudioQueue services for audio playback you can use the AudioFileWritePackets function to write audio data to a file.
If you implement recording this way you can write audio files in the format they're streamed in. So an mp3 audio stream can be written as an mp3 file to disk since you're writing encoded audio packets with the AudioFileWritePackets function.
To get a better understanding of how this all should be implemented you can have a look at the SpeakHere sample code of Apple. The SpeakHere project records from the microphone but it's still a good example to see how the AudioFileWritePackets function works. In your case you need to use the AudioFileWritePackets function in the output callback of your AudioQueue. This is the callback that's called when a buffer is finished playing. So it's a good to place to write the already played audio buffers data to a file.