[FFmpeg-devel] Trouble with GSM audio.

Michel Bardiaux mbardiaux
Tue Oct 2 16:35:13 CEST 2007


Artem Korneev a ?crit :
> Michel Bardiaux wrote:
>> Artem Korneev a ?crit :
>>   
>>> Last weeks I spent in attempting to decode audio frames from GSM format 
>>>     
>> There aint no such animal. You probably mean GSM *codec*, in a wav, right?
>>   
> Hmm.. I have a frames, which comes from the network. And I know, that 
> these frames contains audio in GSM.
> 
>>> to PCM. But I still have no solution. :(
>>>
>>> I've initialize codec context by these lines:
>>>
>>>     inCtx->bit_rate       = 13000;
>>>     inCtx->sample_rate    = 8000;
>>>     inCtx->channels       = 1;
>>>
>>> and after that, decode buffer with GSM audio by this code:
>>>
>>>     while ( in_size > 0 ) {
>>>         outbuf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
>>>         decoded_len = avcodec_decode_audio2(inCtx, samples_ptr, 
>>> &outbuf_size, inbuf_ptr, in_size);
>>>
>>>         in_size     -= decoded_len;
>>>         inbuf_ptr   += decoded_len;
>>>         samples_ptr += outbuf_size;
>>>     }
>>>
>>> ..and only noise I have as result. :( Does anybody have a workable 
>>> example of code for decoding GSM?
>>>     
>> Yes: ffmpeg.c!
>>   
> This source use decoding from the file, as I know. But I need to use it 
> with the buffer, which contains frame.
>> Please try ffmpeg -i on your input.
>>   
> I have no input files, so I tried this command with the dump (I save all 
> incoming frames into the dump file):
> 
> % ffmpeg -i 
> dumpgsm1.gsm                                                                                          
> /tmp
> FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.

rUNKNOWN indicates you probably have an oldish version (current svn does 
correctly set the version number). Better upgrade, dont forget make 
distclean.

>   configuration: --enable-libfaac --enable-libfaad --enable-libmp3lame 
> --enable-libgsm --prefix=/usr/ --disable-ffserver --disable-debug 
> --disable-static --enable-shared --enable-pthreads --enable-gpl
>   libavutil version: 49.3.0
>   libavcodec version: 51.38.0
>   libavformat version: 51.10.0
>   built on Sep 26 2007 18:41:17, gcc: 4.1.2 20061115 (prerelease) 
> (Debian 4.1.1-21)
> dumpgsm1.gsm: Unknown format
> 
> But when I feed this file to gpe-soundbite (gpe-soundbite play 
> dumpgsm1.gsm), I have hear a correctly sound. So, I think, that input is 
> correct.
>> Chances are, its not GSM but GSM-MS. Is the codec_id right?
>>   
> May be, but I'm already tried to use CODEC_ID_GSM_MS as well as 
> CODEC_ID_GSM. No result yet. :(

OK, I have found

http://www.handhelds.org/moin/moin.cgi/GPESoundbiteConversionToMP3

which implies your gsm file is in 'toast' format, ie GSM frames without 
any wrappings, and NOT GSM-MS. Unfortunately toast format is not yet 
supported by ffmpeg; I thought it was almost never used, but if 
gpesoundbite becomes popular...

So, with the ID_GSM codec, it should work. But we dont have all your code...

I have some code that decodes toast independently of ffmpeg, Could you 
publish your .gsm file? (Or if its small, you can send it to me peronal 
mail).

BTW this belongs on ffmpeg-user. -dev is for development *of*, not 
*using*, ffmpeg.

Greetings,
-- 
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/




More information about the ffmpeg-devel mailing list