Error when reading sound in avi files
Afficher commentaires plus anciens
Hello, i whould like to make an aplication that add volume to a film.
In my code i have used a bucle in order to match the audio with the frames. But i found a problem that when reading audio from a film it has a lot of samples that are at 0 value, thoose samples introduce me a lot of distorsion in the audio. When i read a video in mp4 it doesent give me that distorsion because the sound doesen`t have void samples. I whould appreciate if you could healp me. I attach my code in order to explain better

In that picture i have read a mp4 video file that doesen't introduce distorsion.

Same experiment but reading a film.

Same experiment but with other film.
I suppose that this distorison is due the compression of the audiofile but i thought that the dsp.AudioReaderFile function could uncompress that sound.
Those films with distorison are correctly heared in a videoplayer like VLC.
Réponses (1)
Walter Roberson
le 14 Fév 2021
0 votes
MATLAB use the model that audio is attached to the frame, and that each frame has the same amount of audio. If the source does not have the same amount of audio as the first frame, then MATLAB zero fills.
For fixed-framerate video this is an more acceptable model, as lack of audio in such a case can be tied directly to silence for a fixed period.
But for variable-framerate video, the assumption of the same amount of audio for each frame when the frames are not spaced equally presents obvious problems.
I do not know how one might get around this problem.
I wonder, though... perhaps if you fetched the timestamp for each frame as you read it, then the difference in timestamps would give you information on how much audio should have been expected, and then maybe you can chop the buffer if it should have been short?
5 commentaires
Hermenegildo Bello García
le 14 Fév 2021
Hermenegildo Bello García
le 15 Fév 2021
Walter Roberson
le 15 Fév 2021
Interlaced sound? How does that work? Is it multiple channel sound?
Hermenegildo Bello García
le 16 Fév 2021
Hermenegildo Bello García
le 16 Fév 2021
Catégories
En savoir plus sur Audio I/O and Waveform Generation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


