Carl
- https://www.codecguide.com/klcp_ability_comparison.htm - список поддерживаемых кодеков (втч и G.7xx)
-
- rtpg722depay Extracts G722 audio from RTP packets
- samples
Audio Channel Manipulation
Пример G.711 в mka
По описанию тут https://lists.libav.org/pipermail/libav-user/2009-September/003809.html
Файл 32.mp3 взят отсюда http://www.kozco.com/tech/soundtests.html
Преобразование:
$ ffmpeg -i 32.mp3 -acodec pcm_alaw -ac 1 -ar 8000 -ab 40000 32.mka ffmpeg version 3.2.5-1~bpo8+1 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 4.9.2 (Debian 4.9.2-10) configuration: --prefix=/usr --extra-version='1~bpo8+1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --disable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared libavutil 55. 34.101 / 55. 34.101 libavcodec 57. 64.101 / 57. 64.101 libavformat 57. 56.101 / 57. 56.101 libavdevice 57. 1.100 / 57. 1.100 libavfilter 6. 65.100 / 6. 65.100 libavresample 3. 1. 0 / 3. 1. 0 libswscale 4. 2.100 / 4. 2.100 libswresample 2. 3.100 / 2. 3.100 libpostproc 54. 1.100 / 54. 1.100 Input #0, mp3, from '32.mp3': Duration: 00:00:32.05, start: 0.025057, bitrate: 128 kb/s Stream #0:0: Audio: mp3, 44100 Hz, mono, s16p, 128 kb/s Metadata: encoder : LAME3.98r Output #0, matroska, to '32.mka': Metadata: encoder : Lavf57.56.101 Stream #0:0: Audio: pcm_alaw ([6][0][0][0] / 0x0006), 8000 Hz, mono, s16, 64 kb/s Metadata: encoder : Lavc57.64.101 pcm_alaw Stream mapping: Stream #0:0 -> #0:0 (mp3 (native) -> pcm_alaw (native)) Press [q] to stop, [?] for help size= 259kB time=00:00:32.00 bitrate= 66.4kbits/s speed= 790x video:0kB audio:250kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.681250%
Выдача MediaInfo:
General Unique ID : 17719613707446459289158434415458592130 (0xD54AC6826989681F1A8D31D845F2582) Complete name : C:\zorin\Fedor\CaRL\my-tests\32.mka Format : Matroska Format version : Version 4 / Version 2 File size : 259 KiB Duration : 32 s 0 ms Overall bit rate : 66.4 kb/s Writing application : Lavf57.56.101 Writing library : Lavf57.56.101 ErrorDetectionType : Per level 1 Audio ID : 1 Format : ADPCM Format profile : A-Law Codec ID : A_MS/ACM / 6 Codec ID/Hint : CCITT Duration : 32 s 0 ms Bit rate : 64.0 kb/s Channel(s) : 1 channel Sampling rate : 8 000 Hz Bit depth : 8 bits / 8 bits Stream size : 250 KiB (96%) Writing library : Lavc57.64.101 pcm_alaw Default : Yes Forced : No
Воспроизведение нескольких аудио-дорожек
-
- Аудиодорожки — VLC, например. Media — Advanced Open File — Show more options.
- В данном случае поможет BSPlayer — в «Audio streams» в окошке «Audio stream selection» указываете какие дорожки видеофайла BSPlayer должен играть одновременно.
Представление кодеков
в matroska
- TrackEntry.CodecID =
A_MS/ACM
- TrackEntry.CodecPrivate для
A_MS/ACM
содержит структуруWAVEFORMATEX
Описание структуры WAVEFORMATEX
typedef struct { WORD wFormatTag; WORD nChannels; DWORD nSamplesPerSec; DWORD nAvgBytesPerSec; WORD nBlockAlign; WORD wBitsPerSample; WORD cbSize; } WAVEFORMATEX;
wFormatTag - A complete list of format tags can be found in the Mmreg.h header file
#define WAVE_FORMAT_ALAW 0x0006 /* Microsoft Corporation */ #define WAVE_FORMAT_MULAW 0x0007 /* Microsoft Corporation */ #define WAVE_FORMAT_G723_ADPCM 0x0014 /* Antex Electronics Corporation */ #define WAVE_FORMAT_G721_ADPCM 0x0040 /* Antex Electronics Corporation */ #define WAVE_FORMAT_G728_CELP 0x0041 /* Antex Electronics Corporation */ #define WAVE_FORMAT_G726_ADPCM 0x0064 /* APICOM */ #define WAVE_FORMAT_G722_ADPCM 0x0065 /* APICOM */ #define WAVE_FORMAT_G729A 0x0083 /* AT&T Labs, Inc. */ #define WAVE_FORMAT_DF_G726 0x0085 /* DataFusion Systems (Pty) (Ltd) */ #define WAVE_FORMAT_DF_GSM610 0x0086 /* DataFusion Systems (Pty) (Ltd) */
Opus
-
- rfc 7845 Ogg Encapsulation for the Opus Audio Codec
- http://forum.doom9.org/showthread.php?t=167854 If MKVToolnix can mux Opus into Matroska file now
-
Audio ID : 2 Format : Opus Codec ID : A_OPUS Duration : 9mn 28s Channel(s) : 2 channels Channel positions : Front: L R Sampling rate : 48.0 KHz Compression mode : Lossy Title : Track 1 Default : Yes Forced : No
RTP
RTP Timestamp
-
- Audio RTP payload formats typically uses an 8Khz clock. Then take the first audio sample containing e.g. 20ms and assign this timestamp t = 0. 20 ms is a 1/50 of a second, hence this equals a 8000/50 = 160 timestamp increment for the following sample. In the case of audio you can calculate the sample duration based on the sample rate, bits per sample, and number of channels. In the case of a live source, the sample might be timestamped already, and you simply have to translate the timestamp to an RTP timestamp.
- A good reference for RTP in general can be found in the Colin Perkins book, RTP - Audio and video for the Internet. While some of the information might be outdated, it will give you a good understanding of RTP.
RTP Payload Type
Типы определены тут: Профили данных RTP
Пример создания KaxSimpleBlock
https://github.com/neolynx/tvdaemon/blob/master/lib/Matroska.cpp
KaxSimpleBlock &simpleblock = AddNewChild<KaxSimpleBlock>( *cluster ); //KaxSimpleBlock *simpleblock = new KaxSimpleBlock( ); simpleblock.SetParent( *cluster ); simpleblock.AddFrame( *track, ts * timecode_scale, *frame, LACING_EBML ); simpleblock.SetKeyframe( type == DVB_MPEG_ES_FRAME_I ); simpleblock.SetDiscardable( type == DVB_MPEG_ES_FRAME_B ); //KaxBlockBlob *blob = new KaxBlockBlob( BLOCK_BLOB_ALWAYS_SIMPLE ); //blob->SetParent( *cluster ); //blob->AddFrameAuto( *track, ts * timecode_scale, *frame, LACING_EBML ); ////blob->SetBlockDuration( 50 * timecode_scale ); //cluster->AddBlockBlob( blob ); //cues.AddBlockBlob( simpleblock ); //WriteSegment( );
SIP
Библиотеки
FFmpeg
- Foreign function interface - FFI, упоминается в статьях
- https://github.com/giorgisio/goav - возможная альтернатива
- https://github.com/xfrr/goffmpeg - обертка вокруг исполняемого ffmpeg