How to fix changing sample rate bug - web-audio-api

In my app after I play a video, the default sample rate is changed and the sound becomes chip-munk level.
This answer shows very clear the problem:
// Play a video with audio encoded at 44100 Hz
video.play();
// This will console log 44100
var ctx = new webkitAudioContext();
console.log(ctx.sampleRate);
// Play a video with audio encoded at 48000 Hz
video2.play();
// This will console log 48000
var ctx = new webkitAudioContext();
console.log(ctx.sampleRate);
I could check in the code when the sample rate is changed but before my sound starts I cannot change it. Also this sugests you cannot do that. Refreshing the whole page is also not an option for me.
So is there a way I could properly play my sound after the video?
EDIT:
So I've encoded all the videos and audio to the same sample rate(44100). However, when the app starts on an iPad the first video plays with only 24000 sample rate! although it works fine, another sound starts which is distorted.

Related

Flutter - show video length while recording video

I am using the camera package to record video in my app, via the
CameraController.startVideoRecording() method.
I would like to display the increasing value for the length of the video while recording.
My initial thought was to create a timer. But, I wonder if there is a better solution that is more integrated with the video recording itself, such a a callback/event that I can listen to for the current length of the video or some property related to the video that I can interrogate?
Any suggestions/recommendations or examples are appreciated.
Thanks

Hls play only audio, but video is black

I have an application that uses rtmp nginx for streaming. Configure hls_time 1s. Sometimes when I refresh hls player, it only plays audio and video shows black. I used OBS for streaming with keyframe 2s).
I saw that someone said "Segments will be clipped at keyframes, so unless a keyframe exists every second, hls_time will not be accepted.". So I changed the keyframe 1s and it worked fine.

Make unity play high frequency audio exact like the original wav file for hearing test

I am making a unity hearing test, I already manage to do all the code to play the audios, the problem is that unity is changing the way the files are played, for eg one of the files is 18000 Hz, when I open the file and play out of unity it is imposible to me hear anything, but if I play in unity I can hear it very clearly, what can be messing with the audio?
I am keeping the original audio sample rate and my audio sourcer is with default settings, here is the code to play the audio:
void PlayAudio(AudioClip auc) {
aus.PlayOneShot(auc, 1);
}`
here is the audio source:
as you can see normal settings
Thanks for hearing me
I faced a similar problem and used this script for simple sinewave generation
For audio files I chose FMOD

Rendered audio plays in slow-mo

When decoding the audio data of an mp3 file I fetched, rendering it with my OfflineContext, and exporting it back to a .wav file, the sound is in slo-mo with a different pitch. Is it because the sample rates of my mp3 file and OfflineContext are different? If it is, how can I export the mp3 file in a different sample rate while not changing the pitch?
Edit:
I run decodeAudioData with the OfflineAudioContext that I use for the rendering: offlineContext.decodeAudioData(this.arrayBuffer). The sample rate of offlineContext is 48000, while the sample rate of my audioContext (used for normal playback, which works well) is 41000.
While creating the WAV file, the same sample rate than the offline context should be set in the WAV file header. For example, a WAV file with a sample rate of 44100 in the header that contains data chunks with a sample rate of 48000 will cause the playback to be in "slow motion" in iTunes.

AVFoundation created video won't upload to Facebook

I'm working on an app that create a video from a collection of frames using AVFoundation, adds an audio track and uploads to Facebook. I've previously had this working successfully, but it now appears to be failing and I can't find the issue with the format of the video.
An example video is available here: http://www.sendspace.com/file/6p8u11
It should be a Quicktime movie with H.264 and AAC audio. This ought to be ok, but perhaps something about the frame size or frame rate are an issue?
Hope someone can help.
Thanks,
J