[Libav-user] Audio quality loss while encoding

Pradeep Karosiya praks411 at gmail.com
Wed Apr 24 15:24:51 CEST 2013


I also tried with 400000 however the voice is bit clear but whenever music
comes it is distorted.

With ffmpeg application it is working fine the output is same as input in
quality.

So I guess I'm missing something. Also the quality is good for mono but
stereo is bit distorted. 

Another thing which I want to share is that I'm getting decoded audio sample
from ffms2 (aka ffmpegsource).

Here is the snippet of code which is give decoded audio. Since decoded audio
is already in AV_SAMPLE_FMT_FLTP, I'm just passing them as it is to encoder
with doing any kind to conversion.
The decoded samples are set in m_audio_sample (buffer class), then total
sample length is set in byte based on bytes_per_sample and num_channel.
Note that ffms2 gives the decoded samples in one large buffer for both
planar and non-planar format.

  if(m_audio_set && (m_finished_aud_enc == false))
   {
        m_audio_mux_sample->ResetSampleValue();
        int dres =
GetDecodedAudioSamples(m_audio_mux_sample->GetAudioSampleData(),
audio_start_pos, num_request);
	   
        if(num_request < 1536)
        {
            sample_len = 1536;
        }
        else
        {
            sample_len = num_request;   
        }
        m_audio_mux_sample->SetAudioSampleLen(
num_request*m_audio_specs->byte_per_sample*m_audio_specs->num_channels);
	    audio_start_pos += num_request;
        num_samples_rem -= num_request;
        if(num_samples_rem <= 0)
	    {
		   num_samples_rem = 0;
           num_request = 0;
           m_finished_aud_enc = true;
	    }
        else
        {
           num_request = (num_samples_rem <
aud_frame_req)?num_samples_rem:aud_frame_req;
           if(audio_start_pos >= m_audio_specs->total_samples_audio -1)
	       {
		      audio_start_pos = 0;
	       }
        }
    }
}

Do I need to take care memory alignment while allocating buffer in buffer
class (m_audio_mux_sample).



--
View this message in context: http://libav-users.943685.n4.nabble.com/Audio-quality-loss-while-encoding-tp4657364p4657368.html
Sent from the libav-users mailing list archive at Nabble.com.


More information about the Libav-user mailing list