【错误记录】FFmpeg 推流报错 ( FLV does not support sample rate 8000, choose from (44100, 22050, 11025) )
生活随笔
收集整理的這篇文章主要介紹了
【错误记录】FFmpeg 推流报错 ( FLV does not support sample rate 8000, choose from (44100, 22050, 11025) )
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 一、報錯信息
- 二、解決方案
一、報錯信息
在 Android 平臺中 , 先使用 MediaRecorder 將從 麥克風 采集到的 音頻壓縮到文件中 ,
使用 交叉編譯的 FFmpeg 可執行程序 , 執行 文件 推流命令 ,
./ffmpeg -re -i 20220331_152049.m4a -f flv rtmp://192.168.1.17:8088/audio提示如下報錯信息 :
walleye:/data/data/cn.zkhw.client/files # ./ffmpeg -re -i 20220331_152049.m4a -f flv rtmp://192.168.1.17:8088/audio ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developersbuilt with gcc 4.8 (GCC)configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=libavutil 55. 17.103 / 55. 17.103libavcodec 57. 24.102 / 57. 24.102libavformat 57. 25.100 / 57. 25.100libavdevice 57. 0.101 / 57. 0.101libavfilter 6. 31.100 / 6. 31.100libswscale 4. 0.100 / 4. 0.100libswresample 2. 0.101 / 2. 0.101libpostproc 54. 0.100 / 54. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20220331_152049.m4a':Metadata:major_brand : mp42minor_version : 0compatible_brands: isommp42creation_time : 2022-03-31 07:20:59com.android.version: 9Duration: 00:00:09.86, start: 0.000000, bitrate: 14 kb/sStream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 12 kb/s (default)Metadata:creation_time : 2022-03-31 07:20:59handler_name : SoundHandle [flv @ 0xe9e24600] FLV does not support sample rate 8000, choose from (44100, 22050, 11025) [flv @ 0xe9e24600] Audio codec mp3 not compatible with flv Output #0, flv, to 'rtmp://192.168.1.17:8088/audio':Metadata:major_brand : mp42minor_version : 0compatible_brands: isommp42com.android.version: 9encoder : Lavf57.25.100Stream #0:0(eng): Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 8000 Hz, mono, fltp (default)Metadata:creation_time : 2022-03-31 07:20:59handler_name : SoundHandleencoder : Lavc57.24.102 libmp3lame Stream mapping:Stream #0:0 -> #0:0 (aac (native) -> mp3 (libmp3lame)) Could not write header for output file #0 (incorrect codec parameters ?): Function not implemented 1|walleye:/data/data/cn.zkhw.client/files # 1|walleye:/data/data/cn.zkhw.client/files # 1|walleye:/data/data/cn.zkhw.client/files # 1|walleye:/data/data/cn.zkhw.client/files # 1|walleye:/data/data/cn.zkhw.client/files #二、解決方案
MediaRecorder 錄下的音頻 , 默認采樣率為 8000 Hz , FFmpeg 推流不支持該采樣率 ;
FFmpeg 推流只支持 44100, 22050, 11025 三種采樣率 ;
這里設置 MediaRecorder 的采樣率為 11025 Hz 即可 ;
mMediaRecorder.setAudioSamplingRate(11025);注意要在調用 prepare() 方法之前設置采樣率 , 否則無效 ;
總結
以上是生活随笔為你收集整理的【错误记录】FFmpeg 推流报错 ( FLV does not support sample rate 8000, choose from (44100, 22050, 11025) )的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Linux 内核】实时调度类 ① (
- 下一篇: 【Linux 内核】实时调度类 ② (