[Libav-user] C++ FFmpeg distorted sound when converting audio

David Norgren david.norgren at hotmail.com
Tue Aug 18 13:18:37 CEST 2015


I'm trying to generate MP4 files containing audio from various files, such as MP3, WAV, OGG, but I'm having some troubles (I'm also putting video in there, but for simplicity's sake I'm omitting that for this question, since I've got that working). My current code opens an audio file, decodes the content and converts it into the MP4 container and finally writes it into the destination file as interleaved frames.It works perfectly for most MP3 files, but when inputting WAV or OGG, the audio in the resulting MP4 is slightly distorted and often plays at the wrong speed (up to many times faster or slower).I've looked at countless of examples of using the converting functions (swr_convert), but I can't seem to get rid of the noise in the exported audio.
Code (for decoding, converting and encoding): http://pastebin.com/ENzeaHpU
I have also tried setting appropriate pts values for outgoing frames, but that doesn't seem to affect the sound quality at all.I'm also unsure how/if I should be allocating the converted data, can av_samples_alloc be used for this? What about avcodec_fill_audio_frame? Am I on the right track?


/David
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20150818/8e1f95ad/attachment.html>


More information about the Libav-user mailing list