技术专栏
rv1126 ffmpeg使用
1.FFMPEG官网
2.FFMPEG错误速查
#define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') ///< Bitstream filter not found
#define AVERROR_BUG FFERRTAG( 'B','U','G','!') ///< Internal bug, also see AVERROR_BUG2
#define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') ///< Buffer too small
#define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') ///< Decoder not found
#define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') ///< Demuxer not found
#define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') ///< Encoder not found
#define AVERROR_EOF FFERRTAG( 'E','O','F',' ') ///< End of file
#define AVERROR_EXIT FFERRTAG( 'E','X','I','T') ///< Immediate exit was requested; the called function should not be restarted
#define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') ///< Generic error in an external library
#define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') ///< Filter not found
#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input
#define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') ///< Muxer not found
#define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found
#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome
#define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found
#define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found
/**
* This is semantically identical to AVERROR_BUG
* it has been introduced in Libav after our AVERROR_BUG and with a modified value.
*/
#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library
#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
#define AVERROR_INPUT_CHANGED (-0x636e6701) ///< Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED)
#define AVERROR_OUTPUT_CHANGED (-0x636e6702) ///< Output changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_INPUT_CHANGED)
/* HTTP & RTSP errors */
#define AVERROR_HTTP_BAD_REQUEST FFERRTAG(0xF8,'4','0','0')
#define AVERROR_HTTP_UNAUTHORIZED FFERRTAG(0xF8,'4','0','1')
#define AVERROR_HTTP_FORBIDDEN FFERRTAG(0xF8,'4','0','3')
#define AVERROR_HTTP_NOT_FOUND FFERRTAG(0xF8,'4','0','4')
#define AVERROR_HTTP_OTHER_4XX FFERRTAG(0xF8,'4','X','X')
#define AVERROR_HTTP_SERVER_ERROR FFERRTAG(0xF8,'5','X','X')
一些常见的FFERRTAG的值转换ionic
AVERROR_BSF_NOT_FOUND = -1179861752
AVERROR_BUG = -558323010
AVERROR_BUFFER_TOO_SMALL = -1397118274
AVERROR_DECODER_NOT_FOUND = -1128613112
AVERROR_DEMUXER_NOT_FOUND = -1296385272
AVERROR_ENCODER_NOT_FOUND = -1129203192
AVERROR_EOF = -541478725
AVERROR_EXIT = -1414092869
AVERROR_EXTERNAL = -542398533
AVERROR_FILTER_NOT_FOUND = -1279870712
AVERROR_INVALIDDATA = -1094995529
AVERROR_MUXER_NOT_FOUND = -1481985528
AVERROR_OPTION_NOT_FOUND = -1414549496
AVERROR_PATCHWELCOME = -1163346256
AVERROR_PROTOCOL_NOT_FOUND = -1330794744
AVERROR_STREAM_NOT_FOUND = -1381258232
AVERROR_BUG2 = -541545794
AVERROR_UNKNOWN = -1313558101
AVERROR_EXPERIMENTAL = -733130664
AVERROR_INPUT_CHANGED = -1668179713
AVERROR_OUTPUT_CHANGED = -1668179714
AVERROR_HTTP_BAD_REQUEST = -808465656
AVERROR_HTTP_UNAUTHORIZED = -825242872
AVERROR_HTTP_FORBIDDEN = -858797304
AVERROR_HTTP_NOT_FOUND = -875574520
AVERROR_HTTP_OTHER_4XX = -1482175736
AVERROR_HTTP_SERVER_ERROR = -1482175992
3.拉流推流命令
1.拉rtsp流,然后通过rtmp推送出去:
ffmpeg -i rtsp://admin:12345@192.168.0.200:554/Streaming/Channels/1 -vcodec copy -acodec copy -f flv rtmp://192.168.0.31:1935/live/test123
2.将H265的视频流转码成H264的:
ffmpeg -y -vcodec hevc -i glw265.flv -acodec copy -vcodec libx264 glw264.flv
3.将H265的rtsp流拉下来,解码,然后再编码成H264的流,通过rtmp推送出去。
ffmpeg -y -vcodec hevc -i rtsp://192.168.0.132:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream -acodec copy -vcodec libx264 -vb 2048000 -f flv rtmp://192.168.0.32:1935/live/mainstream
4.将uvc的视频通过rtmp推送出去。
ffmpeg -r 25 -s 640x480 -i /dev/video10 -b:v 3000k -qscale 1 -c:a copy -pix_fmt yuv420p -f flv rtmp://192.168.0.30:1935/live/test123
5.本地mp4文件通过rtsp推送出去。
ffmpeg -re -i receive.mp4 -vcodec copy -codec copy -f rtsp rtsp://192.168.0.35/pusher
6.拉取rtsp视频流存H264文件
ffmpeg -i rtsp://admin:fs123456@192.168.0.66:554/Streaming/Channels/101 -c:v copy -an -bsf:v h264_mp4toannexb out.h264
7.拉取rtsp视频流存flv文件
ffmpeg -i "rtsp://admin:fs123456@192.168.0.66:554/Streaming/Channels/101" -vcodec copy -acodec copy -f flv "test.flv"
8.拉取rtsp视频流通过rtmp推送出去
ffmpeg -i rtsp://admin:fs123456@192.168.0.66:554/Streaming/Channels/101 -vcodec copy -acodec copy -f flv rtmp://192.168.0.35:1935/live/test123
9.本地.h264文件通过rtmp推送出去
ffmpeg -re -stream_loop -1 -i h265_encode.h264 -vcodec copy -acodec copy -f flv -y rtmp://127.0.0.1:1935/live/mainstream
10.拉rtsp流添加中文水印推rtmp流出去
ffmpeg -i rtsp://admin:fs123456@192.168.0.66:554/Streaming/Channels/101 -vf "drawtext=fontfile=simfang.ttf: text='中文水印测试':x=10:y=10:fontsize=24:fontcolor=red:shadowy=2" -c:v libx264 -c:a copy -f flv rtmp://192.168.0.30:1935/live/substream
注意:需要字库支持
11.将1080p h265编码的mp4文件转成960*540分辨率 h264编码mp4文件:
ffmpeg -i test-h265-10min.mp4 -vf scale=960:540 video-960x540-h265.mp4 -hide_banner
注意:转换之后,分辨率降低了,码率也降低了,清晰度受影响。
12.拉取rtsp流,加入sei信息,推rtmp流出去
ffmpeg -i rtsp://admin:fs123456@192.168.0.66:554/Streaming/Channels/101 -c copy -bsf:v h264_metadata=sei_user_data='086f3693b7b34f2c965321492feee5b8+hello' -an -y -f flv rtmp://192.168.0.36:1935/live/teststream
4.rv1126上编译调试
1.编译ffmpeg,可以直接到
/home/zl/firefly-workspace/rv1126_rv1109_linux_release_20210306/buildroot/output/firefly_rv1126_rv1109/build/ffmpeg-4.1.3
目录下,make,然后更新的动态库直接拷贝到板子上,这样来调试查看流程,如果要修改的话,得修改ffmpeg的压缩包,或者打patch。
2.编译librtmp:
sdk根目录下运行下面的命令:
make rtmpdump-rebuild
将生成的动态库也是拷贝到板子上调试
5.接口过时问题
ffmpeg很多网上的例程,用的都是ffmpeg早期的版本,编译的时候会提示:
warning: ‘AVBitStreamFilterContext* av_bitstream_filter_init(const char*)’ is deprecated (declared at /home/zl/vstdio-workspace/hi3536-webapp/nvrserver/libs/ffmpeg/include/libavcodec/avcodec.h:6022) [-Wdeprecated-declarations]
h264bsfc = av_bitstream_filter_init("hevc_mp4toannexb");
这些可以作为警告信息忽略掉,不会影响执行,但是为了功能长期考虑,最好还是替换新接口。
1.av_bitstream_filter_init过时
该接口为老版本,用法如下:
//声明:
AVBitStreamFilterContext* h264bsfc = av_bitstream_filter_init("h264_mp4toannexb");
//使用
av_bitstream_filter_filter(h264bsfc, in_stream->codec, NULL, &pkt.data, &pkt.size, pkt.data, pkt.size, 0);
//释放:
av_bitstream_filter_close(h264bsfc);
新版本用法:
//声明
AVBSFContext *bsf_ctx = nullptr;
const AVBitStreamFilter *pfilter = av_bsf_get_by_name("h264_mp4toannexb");
av_bsf_alloc(pfilter, &bsf_ctx);
//使用:
av_bsf_send_packet(bsf_ctx, &packet);
av_bsf_receive_packet(bsf_ctx, &packet);
//释放:
av_bsf_free(&bsf_ctx);
6.查看某个编码支持的像素
ffmpeg -h encoder=mjpeg
声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
红包
点赞
收藏
评论
打赏
- 分享
- 举报
评论
0个
手气红包
暂无数据
相关专栏
-
浏览量:1298次2024-05-24 17:11:01
-
浏览量:984次2023-10-26 10:43:59
-
浏览量:1221次2024-01-09 17:35:19
-
2024-01-05 17:19:54
-
浏览量:2534次2023-06-28 17:22:40
-
浏览量:965次2023-08-30 18:37:06
-
浏览量:731次2024-01-02 09:46:50
-
浏览量:3984次2021-06-18 16:05:42
-
浏览量:1430次2024-02-27 17:03:43
-
浏览量:2488次2023-11-29 08:59:50
-
浏览量:1207次2023-12-07 00:53:19
-
浏览量:1253次2023-08-31 16:23:55
-
浏览量:782次2023-12-25 14:23:01
-
浏览量:620次2023-11-28 14:16:24
-
浏览量:619次2024-02-29 16:42:40
-
浏览量:1559次2024-01-04 17:26:55
-
浏览量:975次2023-11-10 15:08:11
-
浏览量:1437次2024-01-27 16:28:20
-
浏览量:655次2023-12-21 16:28:56
置顶时间设置
结束时间
删除原因
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
打赏作者
林
您的支持将鼓励我继续创作!
打赏金额:
¥1
¥5
¥10
¥50
¥100
支付方式:
微信支付
打赏成功!
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
审核成功
发布时间设置
发布时间:
请选择发布时间设置
是否关联周任务-专栏模块
审核失败
失败原因
请选择失败原因
备注
请输入备注