FFmpeg / Libav音频解码示例

瓦利德·巴卡里(Walid Baccari)

我试图通过使用代码将MP2文件转换为原始PCM来获得与ffmpeg / avconv相同的输出。我使用了FFmpeg / Libav文档中包含的教程中的audio_decode_example函数,但输出有所不同。

我需要将ffmpeg / avconv命令执行哪些步骤才能将其添加到程序中以获得相同的输出?

编辑:这是来自的输出avconv -v debug -i test.mp2 test.sw

avconv version v10_beta1-302-g606cc8a, Copyright (c) 2000-2014 the Libav developers
built on Mar 20 2014 20:28:32 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
configuration: 
libavutil     53.  6. 0 / 53.  6. 0
libavcodec    55. 34. 1 / 55. 34. 1
libavformat   55. 12. 0 / 55. 12. 0
libavdevice   54.  0. 0 / 54.  0. 0
libavfilter    4.  3. 0 /  4.  3. 0
libavresample  1.  2. 0 /  1.  2. 0
libswscale     2.  1. 2 /  2.  1. 2
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set libav* logging level) with argument 'debug'.
Reading option '-i' ... matched as input file with argument 'test.mp2'.
Reading option 'test1.sw' ... matched as output file.                                  
Finished splitting the commandline.                                       
Parsing a group of options: global .                
Applying option v (set libav* logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file test.mp2.
Successfully parsed a group of options.
Opening an input file: test.mp2.
[mp3 @ 0x27e5060] Probed with size=2048 and score=51
[mp3 @ 0x27e5060] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, mp3, from 'test.mp2':
  Duration: 00:00:04.80, start: 0.000000, bitrate: 64 kb/s
    Stream #0.0, 200, 1/14112000: Audio: mp2, 48000 Hz, stereo, s16p, 64 kb/s
Successfully opened the file.
Parsing a group of options: output file test1.sw.
Successfully parsed a group of options.
Opening an output file: test1.sw.
Successfully opened the file.
Detected 2 logical cores.
[abuffer @ 0x27e5860] tb:1/48000 samplefmt:s16p samplerate: 48000 ch layout:0x3
[abuffersink @ 0x2807040] auto-inserting filter 'auto-inserted fifo 0' between the filter 'audio format for output stream 0:0' and the filter 'output stream 0:0'
[aformat @ 0x2806bc0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed filter 0 anull' and the filter 'audio format for output stream 0:0'
[AVAudioResampleContext @ 0x28092a0] audio_convert: found function: s16p to s16  (C)
[AVAudioResampleContext @ 0x28092a0] audio_convert: found function: s16p to s16  (SSE2)
[resample @ 0x2808560] fmt:s16p srate:48000 cl:stereo -> fmt:s16 srate:48000 cl:stereo
Output #0, s16le, to 'test1.sw':
  Metadata:
    encoder         : Lavf55.12.0
    Stream #0.0, 0, 1/90000: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
  Stream mapping:
    Stream #0:0 -> #0:0 (mp2 -> pcm_s16le)
Press ctrl-c to stop encoding
Input stream #0:0 frame changed from rate:48000 fmt:s16p ch:2 chl:stereo to rate:48000 fmt:s16 ch:2 chl:stereo
Detected 2 logical cores.
[abuffer @ 0x2806e40] tb:1/48000 samplefmt:s16 samplerate: 48000 ch layout:0x3
[abuffersink @ 0x2806fa0] auto-inserting filter 'auto-inserted fifo 0' between the filter 'audio format for output stream 0:0' and the filter 'output stream 0:0'
No more output streams to write to, finishing.
size=     900kB time=4.80 bitrate=1536.0kbits/s    
video:0kB audio:0kB global headers:0kB muxing overhead 0.000000%
伊沃·安多诺夫(Ivo Andonov)

我有同样的问题。默认情况下,libav mp2解码似乎是以S16P格式(平面)输出的,这在支持原始输入(例如音频)的各种音频编辑应用程序中并不常见。我通过在AVCodecContext中将request_sample_fmt指定为AV_SAMPLE_FMT_S16解决了我的问题。因此,无需额外进行软件重采样。

在函数audio_decode_example中:

...
c = avcodec_alloc_context3(codec);
if (!c) {
    fprintf(stderr, "Could not allocate audio codec context\n");
    exit(1);
}
c->request_sample_fmt = AV_SAMPLE_FMT_S16;
...

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用FFMPEG LibAV重采样音频

来自分类Dev

C ++ H264 ffmpeg / libav编码/解码(无损)问题

来自分类Dev

ffmpeg解码示例使用vda加速?

来自分类Dev

使用ffmpeg将音频批量转换(解码)为多种格式

来自分类Dev

复制解码的ffmpeg AVFrame

来自分类Dev

使用FFmpeg解码WebP

来自分类Dev

音频样本格式s16p,ffmpeg或音频编解码器错误?

来自分类Dev

FFMPEG音频未录制

来自分类Dev

ffmpeg不转换音频

来自分类Dev

FFmpeg音频相位反转

来自分类Dev

FFMPEG zoompan滤镜示例

来自分类Dev

使用Libav的视频原始音频解码被切碎

来自分类Dev

ffmpeg / ffprobe获取视频/音频流的HLS'编解码器'字符串

来自分类Dev

想更改音频编解码器,但使用ffmpeg保留视频设置

来自分类Dev

ffmpeg-通过RTP通过vorbis编解码器流式传输音频

来自分类Dev

Set RTSP/UDP buffer size in FFmpeg/LibAV

来自分类Dev

用 libav / ffmpeg 替换 Bento4

来自分类Dev

FFmpeg将音频淡入音量

来自分类Dev

ffmpeg添加静音音频通道

来自分类Dev

网络流视频+音频FFmpeg

来自分类Dev

FFMPEG Directshow多个音频捕获

来自分类Dev

如何使用ffmpeg规范音频?

来自分类Dev

FFmpeg修剪音频并调节音量

来自分类Dev

FFmpeg跳过音频文件

来自分类Dev

FFMPEG 音频问题 Youtube Live

来自分类Dev

ffmpeg:使用ffmpeg将图像/音频转换为视频

来自分类Dev

使用ffmpeg进行编码以实现最快的解码

来自分类Dev

FFmpeg本机AAC解码器

来自分类Dev

FFmpeg:解码从 UDP 套接字接收的 AVPackets