mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
74 lines
2.1 KiB
Markdown
74 lines
2.1 KiB
Markdown
# 1. ffmpeg开发文档
|
||
|
||
## 1.1. ffplay命令使用
|
||
|
||
* 播放G711a音频文件
|
||
|
||
```code
|
||
$ ffplay -i audio.g711a -f alaw -ac 1 -ar 8000
|
||
```
|
||
ffmpeg -i input.g711a -acodec alaw output.wav
|
||
|
||
* 播放h264视频文件
|
||
|
||
```code
|
||
$ ffplay video.h264
|
||
```
|
||
|
||
* g711a音频文件转wav音频文件
|
||
|
||
```code
|
||
$ fmpeg -f mulaw -ar 8000 -i audio.g711a audio.wav
|
||
```
|
||
|
||
* 将h264和wav文件合成mp4文件
|
||
|
||
**注意:未发现可以将h264和g711a文件合成mp4文件**
|
||
|
||
```code
|
||
$ ffmpeg -i video.h264 -i audio.wav -c:v copy -c:a aac -b:a 96k test.mp4
|
||
```
|
||
|
||
## 1.2. 问题记录
|
||
|
||
### 1.2.1. avformat_open_input 执行失败
|
||
|
||
  在执行avformat_open_input时,返回-1094995529<0,错误
|
||
|
||
解决:在Ubuntu编译时,使能所有的编译选项,并且把--arch=赋值为linux
|
||
|
||
```code
|
||
# 详见://external/ffmpeg/CMakeLists.txt
|
||
set(CONFIGURE_COMMAND "--enable-cross-compile --target-os=linux --arch=linux \
|
||
--cc=${CMAKE_C_COMPILER} \
|
||
--cxx=${CMAKE_CXX_COMPILER} \
|
||
--prefix=${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg \
|
||
--enable-parsers --enable-decoder=h264 \
|
||
--enable-ffmpeg --enable-shared --enable-static \
|
||
--enable-gpl --enable-nonfree --enable-version3 --enable-small \
|
||
--enable-muxer=mov --enable-muxer=mp4 \
|
||
--enable-decoder=aac \
|
||
--enable-demuxer=mov \
|
||
--enable-protocol=file --enable-bsf=aac_adtstoasc --enable-bsf=h264_mp4toannexb --enable-bsf=hevc_mp4toannexb")
|
||
```
|
||
|
||
### 1.2.2. avformat_open_input 执行失败
|
||
|
||
  打开g711a文件时,提示无效数据。如下:
|
||
**Invalid data found when processing input**
|
||
|
||
解决:
|
||
调用 avformat_open_input 函数时,指定输入文件的格式(第三个参数),g711a文件格式为:alaw。
|
||
|
||
```code
|
||
# //utils/MediaBase/src/MediaBaseImpl.cpp
|
||
const AVInputFormat *iformat = av_find_input_format(InputFormat(mType));
|
||
AVFormatContext *pFormatCtx = nullptr;
|
||
if ((result = avformat_open_input(&pFormatCtx, path.c_str(), iformat, nullptr)) < 0) {
|
||
char error_str[AV_ERROR_MAX_STRING_SIZE] = {0};
|
||
av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, result);
|
||
LogError("Couldn't open file: %s, result=%s\n", path.c_str(), error_str);
|
||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||
}
|
||
```
|