Invalid sample rate While recording an audio - audio

I have two microphones Blue microphone - snow ball ice and Stage line microphone (EMG-500P, DMS-1 microphone base, MPR-1 pre-amp, soundcard as shown in the image below).
I am using a python sound device library example from git and i working fine. Audio recording from Blue microphone is working fine for many different sampling rate like 16000, 44100, 48000 etc (-r = 16000/44100/48000) but Stage line microphone is recording audio only when sampling rate are 44100 or 48000 Hz. Any sampling rate other than 44100/48000 Hz its throwing an error.
PortAudioError: Error opening InputStream: Invalid sample rate
[PaErrorCode -9997]
How can i record at 16KHz from Stage line microphone ?
Why am I not able to sample at 16kHz ? Is it because of sound card ?
I am using sound device python example exact code to record both from Blue microphone and Stage line microphone.
Thanks.

Related

How is the AAC encoder priming delay handled in HLS?

As per Apple, in AAC encoding 2112 priming samples are added at the beginning of audio. When creating HLS stream with AAC audio, will these priming samples be added to the beginning of each HLS segment or only to the first HLS segment? And, how does this AAC encoder delay affect HLS DISCONTINUITY tags later in the HLS stream?
https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
I depends on the AAC you use.
For 'old-style' AAC-LC you only have priming samples at the beginning of the stream and not at the beginning of each segment.
But the delay is carried through the entire stream.
Typically a new piece of media is displayed after a DISCONTINUITY tag - for example an advertisement - so you will receive another set of priming samples.
Your AAC audio decoder needs to discard the priming samples (first 2112) PCM output samples after startup and after DISCONTINUITY.
If you use the more modern xHE-AAC - you don't have to worry about priming samples anymore.
Another wrinkle - in the early days it was just assumed that AAC-LC has 2112 priming samples.
Now the number can be different and it can be signaled in the MP4 container as Edit-List.

Problem understanding audio stream number of samples when decoded with ffmpeg

The two streams I am decoding are an audio stream (adts AAC, 1 channel, 44100, 8-bit, 128bps) and a video stream (H264) which are received in an Mpeg-Ts stream, but I noticed something that doesn't make sense to me when I decode the AAC audio frames and try to line up the audio/video stream timestamps. I'm decoding the PTS for each video and audio frame, however I only get a PTS in the audio stream every 7 frames.
When I decode a single audio frame I get back 1024 samples, always. The frame rate is 30fps, so I see 30 frames each with 1024 samples which comes equals 30,720 samples and not the expected 44,100 samples. This is a problem when computing the timeline as the timestamps on the frames are slightly different between the audio and video streams. It's very close, but since I compute the timestamps via (1024 samples * 1,000 / 44,100 * 10,000 ticks) it's never going to line up exactly with the 30fps video.
Am I doing something wrong here with decoding the ffmpeg audio frames, or misunderstanding audio samples?
And in my particular application, these timestamps are critical as I am trying to line up LTC timestamps which are decoded at the audio frame level, and lining those up with video frames.
FFProbe.exe:
Video:
r_frame_rate=30/1
avg_frame_rate=30/1
codec_time_base=1/60
time_base=1/90000
start_pts=7560698279
start_time=84007.758656
Audio:
r_frame_rate=0/0
avg_frame_rate=0/0
codec_time_base=1/44100
time_base=1/90000
start_pts=7560686278
start_time=84007.625311

Video is 25fps, audio 50 fps?

In my country we ever use the 25fps(PAL) for video, and for audio.
Yesterday I record a tv movie with vdr(mpeg-ts format) and mediainfo report this for audio and video
Audio is mp2, video h264
Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 2
Codec ID : 4
Duration : 3 h 58 min
Bit rate mode : Constant
Bit rate : 128 kb/s
Channel(s) : 2 channels
Sampling rate : 48.0 kHz
Frame rate : 41.667 FPS (1152 SPF)
Compression mode : Lossy
Delay relative to video : -406 ms
Stream size : 219 MiB (6%)
Video
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High#L3
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Format settings, picture structure : Frame
Codec ID : 27
Duration : 3 h 58 min
Bit rate : 1 915 kb/s
Width : 720 pixels
Height : 576 pixels
Display aspect ratio : 16:9
Frame rate : 25.000 FPS
How is possible audio/video are in sync with a FPS of about 50fps on audio?
If I want to recode it, I have to recode audio on 25fps?
TLDR: You don't have to worry about it. Two different meanings for "frames per second".
MP3 is an interesting file format. It doesn't have a global header that represents the entire file. Instead MP3 is a concatenation of small individual files called "frames". Each frame is a few milliseconds in length. That's why you can often just chop an MP3 file in half and the second half plays just fine. It's what also enables VB3 MP3 to exist. The sample rate or encoding parameters can change at any point in the file.
So your particular MP3 has a "frame rate" of 41.667 frames per second. Now notice the SPF value of 1152 in parentheses. That's "samples per frame". If you do the math: 1152 samples/frame * 41.667 frames/second` is almost exactly 48000 samples per second. Identical to the sampling rate presented by the mediainfo tool.
When a media player plays a video file, it will basically render the video stream separate from the audio stream, so there's very little effort it needs to keep the different sample rates in sync.
As to your question about resampling for video. The encoding tool you use will do the right thing. The FPS for MP3 is completely orthogonal to the video FPS.

Bit rate and sample rate for ogv movie to be played in rpg maker vx ace

I've made a movie for RPG Maker XV ace with just music in the background.
The program only allows .ogv movies (OGG, THEORA) to be played. I have no problem with the video quality, however, the sound is distorted and "jumps"
(like when we were playing records in the '90s..) when there are high pitched or reverberating instruments.
The following are my settings for the movie output:
Container: OGG
Video Codec: Theora
Audio Codec: Vorbis
Bit rate: 160 (16 bit)
Sample rate: 44100 (44.1 kHz)
System: Windows 10
Video Editor: Blender 2.79
The .ogg audio files are perfect when played in RPG Maker Ace by themselves just as audio files. The problem only exists with the audio in .ogv movies.
I have already tried increasing the bit rate and the frame rate but to no avail.
Does anyone know the standard audio requirements for audio in movies for RPG Maker Ace?
Thanks for your help!
I actually disobeyed what RPG Maker suggests in their help menu and made some changes as follow:
CONTAINER: OGG
VIDEO CODEC: H.264
OUTPUT QUALITY: CONSTANT BIT RATE (This is very important)
ENCODING SPEED: Medium
AUDIO CODEC: VORBIS
BIT RATE: 200
FRAME RATE: 48000
Now it works like a charm!

DSP, random glitches resampling audio wave

I'm using a DSP for audio processing, I get an audio input via Bluetooth (a2dp) and I output the processed audio through an analog connector to a headset.
The audio I receive from the Bluetooth device has a frequency of 44100 Hz, and one of the purposes of the DSP is to resample (upsample, downsample) the bluetooth audio to a frequency of my choosing, for example 48000 Hz.
I have already implemented the resampling (the manufacturer of the DSP has the code to do this) but I get random glitches in the output audio, and I have no idea why. The following images show a 400 Hz sine wave being played from the Bluetooth device to the analog output, being resampled from 44100 Hz to 48000 Hz, I connected a jack to this output and measured the resulting wave with an oscilloscope.
I can't find any patterns or something that tells me where to look. I've been trying to find the cause of this for over a week now and so far no success. Anyone have any ideas? I'm a bit desperate.
Please let me know if you need more details.

Resources