[Libav-user] G.711 audio in mkv container

Alex Grosu agrosu at c-s.ro
Fri Sep 23 14:19:29 EEST 2016


Arghh, I forgot to add in my previous mail these settings :

c->sample_fmt = SAMPLE_FMT_S16;

c->flags = CODEC_FLAG_GLOBAL_HEADER;


On 9/23/2016 2:16 PM, Alex Grosu wrote:
>
> One correction,
>
> c->frame_size = 2560 (not 2650, typo)
>
> Sorry for this
>
>
>
> On 9/23/2016 2:13 PM, Alex Grosu wrote:
>> Dear all
>>
>> I am having some issues in creating a G711 audio mkv container with 
>> libavcodec on windows.
>> I set the codec context (header) like this:
>> c->codec_id = CODEC_ID_PCM_ALAW;
>> c->codec_type = CODEC_TYPE_AUDIO;
>> c->bit_rate = 64000;
>> c->sample_rate = 8000;
>> c->channels = 1;
>> c->frame_size = 2650;
>> c->channel_layout = 1;
>> waveFormatEX = malloc(sizeof(WAVEFORMATEXTENSIBLE) + 
>> FF_INPUT_BUFFER_PADDING_SIZE);
>> waveFormatEX->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
>> waveFormatEX->Format.nChannels = 1;
>> waveFormatEX->Format.nSamplesPerSec = 8000;
>> waveFormatEX->Format.wBitsPerSample = 16;
>> waveFormatEX->Format.nBlockAlign = 2;
>> waveFormatEX->Format.nAvgBytesPerSec = 16000;
>> waveFormatEX->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE);
>> waveFormatEX->Samples.wSamplesPerBlock = 0;
>> waveFormatEX->dwChannelMask = KSAUDIO_SPEAKER_MONO;
>> waveFormatEX->SubFormat = KSDATAFORMAT_SUBTYPE_ALAW;
>> c->extradata = (uint8_t*)waveFormatEX;
>> c->extradata_size = waveFormatEX->Format.cbSize;
>>
>> The mkv container is created, ffplay can play it without problems:
>>
>> This is the what ffplay outputs when playing the file:
>>
>> Input #0, matroska,webm, from 'c:\Users\alex\Bus 
>> standard-37-Enregistreur Xebra3
>> --2016-09-15(0h 1m 0s)\Cam 1 Flux audio.mkv':
>>   Metadata:
>>     encoder         : Lavf52.78.1
>>   Duration: 00:01:52.00, start: 0.000000, bitrate: 34 kb/s
>>     Stream #0:0: Audio: pcm_alaw ([6][0][0][0] / 0x0006), 8000 Hz, 1 
>> channels, s
>> 16, 64 kb/s (default)
>>     Stream #0:1(fra): Subtitle: subrip (default)
>>    8.94 M-A: -0.000 fd=   0 aq=  421KB vq=    0KB sq=    0B f=0/0
>>
>> The sound can be heard witthout problems. The file should have ~ 1 
>> minute, but ffplay say the duration is 1:52
>>
>> The vlc player instead has issues in playing the file. The sound is 
>> heard but with "gaps", something related to pts?
>> This is the info from vlc about the file:
>> Type: Audio
>> Codec: PCM ALAW(alaw)
>> Channels: Mono
>> Sample rate: 8000 Hz
>> Bits per sample: 16
>> And here are some warnings while playing the file:
>> corewarning: playback way too early (-170000): playing silence
>>
>> coredebug: inserting 1360 zeroes
>>
>> corewarning: playback way too early (-150000): playing silence
>>
>> coredebug: inserting 1200 zeroes
>>
>> corewarning: playback way too early (-170000): playing silence
>>
>> coredebug: inserting 1360 zeroes
>>
>> corewarning: playback way too early (-150000): playing silence
>>
>>
>>
>> Can somebody please guide how to properly set G.711 
>> (CODEC_ID_PCM_ALAW) in libavcodec?
>> Thank you a lot for reading this long post
>>
>>
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160923/d358b05c/attachment.html>


More information about the Libav-user mailing list