当前位置: 首页 > news >正文

网站的前端怎么做建设工程信息网官网入口查询

网站的前端怎么做,建设工程信息网官网入口查询,网页界面设计的主要内容,电子商务专业网站建设又有一个需求#xff1a;我们现在想做一款多路RTSP拉流转RTMP推流到CDN进行直播的功能#xff0c;注意啊#xff0c;是多路#xff0c;原来我们有两种方式#xff0c;一种是用ffmpeg.exe进行#xff1a; ffmpeg -i “rtsp://192.168.0.99:8554/1” -c:v libx264 -c:a aac…又有一个需求我们现在想做一款多路RTSP拉流转RTMP推流到CDN进行直播的功能注意啊是多路原来我们有两种方式一种是用ffmpeg.exe进行 ffmpeg -i “rtsp://192.168.0.99:8554/1” -c:v libx264 -c:a aac -f flv “rtmp://127.0.0.1:1935/live/test” 同样这种方式会有一个问题那就是断线重连的问题我们不能很好地知道拉流是不是断线了或者当前的推流状态是什么样子的推流中还是重连中同时我们也只能默认重编码成H.264和AAC这种机器性能消耗会很高我们完全可以在源流是H.264或者AAC编码的时候直接-c:v copy或者-c:a copy但是我们不好判断。 每一路流我们先ffprobe一下看看视频编码格式是H.264还是H.265再重新启动ffmpeg.exe拉流转推流 很显然上面的方法搞个几路是没问题的搞多了就不靠谱了维护一堆ffmpeg既不稳定又没成长~ 另一种方式就是用ffmpeg的SDK进行开发avfilter、avcodec一整套获取avformat再把avpacket导给RTMP推流整套下来开发难度较高要工程化的比较稳定还需要老师傅看看大模型咋写的 #include libavformat/avformat.h #include libavutil/time.hint main(int argc, char **argv) {AVFormatContext *pFormatCtx NULL;AVOutputFormat *oFormat NULL;AVStream *in_stream NULL;AVStream *out_stream NULL;AVCodecContext *pCodecCtxIn NULL;AVCodecContext *pCodecCtxOut NULL;AVPacket pkt;int ret, i;if (argc 3) {printf(Usage: %s input RTSP URL output RTMP URL , argv[0]);return -1;}// Register all formats and codecsav_register_all();// Open input RTSP URLif ((ret avformat_open_input(pFormatCtx, argv[1], NULL, NULL)) ! 0) {printf(Cannot open input stream: %s , av_err2str(ret));return -1;}// Retrieve stream informationif ((ret avformat_find_stream_info(pFormatCtx, NULL)) 0) {printf(Cannot find stream information: %s , av_err2str(ret));return -1;}// Find the first audio streamfor (i 0; i pFormatCtx-nb_streams; i) {if (pFormatCtx-streams[i]-codecpar-codec_type AVMEDIA_TYPE_AUDIO) {in_stream pFormatCtx-streams[i];break;}}// If no audio stream is found, exitif (!in_stream) {printf(Didnt find a audio stream! );return -1;}// Get a pointer to the codec context for the audio streampCodecCtxIn in_stream-codec;// Find the first video streamfor (i 0; i pFormatCtx-nb_streams; i) {if (pFormatCtx-streams[i]-codecpar-codec_type AVMEDIA_TYPE_VIDEO) {out_stream pFormatCtx-streams[i];break;}}// If no video stream is found, exitif (!out_stream) {printf(Didnt find a video stream! );return -1;}// Get a pointer to the codec context for the video streampCodecCtxOut out_stream-codec;// Open output RTMP URLif ((ret avformat_alloc_output_context2(pFormatCtx, NULL, flv, argv[2])) 0) {printf(Cannot create output context: %s , av_err2str(ret));return -1;}// Add stream to the output contextif (avformat_new_stream(pFormatCtx, out_stream-codec-codec) 0) {printf(Error adding new stream to output context );return -1;}// Write headerif (avformat_write_header(pFormatCtx, NULL) 0) {printf(Error occurred when opening output file. );return -1;}// Process each packet from input streamwhile (av_read_frame(pFormatCtx, pkt) 0) {// Is this a packet from the audio stream?if (pkt.stream_index in_stream-index) {// Decode audio frameAVCodecContext *pCodecOut pCodecCtxOut;ret avcodec_send_packet(pCodecOut, pkt);if (ret 0) {printf(Error sending a packet for decoding );return -1;}while (ret 0) {ret avcodec_receive_frame(pCodecOut, NULL);if (ret AVERROR(EAGAIN) || ret AVERROR_EOF) {break;} else if (ret 0) {printf(Error during decoding );return -1;}// Write the decoded frame to the output fileav_interleaved_write_frame(pFormatCtx, pkt);}} else if (pkt.stream_index out_stream-index) {// Is this a packet for the video stream?if (pkt.pts in_stream-start_time) {// Write video frameret av_interleaved_write_frame(pFormatCtx, pkt);if (ret 0) {printf(Error during writing );return -1;}}}}// Close the output contextavformat_free_context(pFormatCtx);return 0; } 注意啊以上代码没有经过验证太麻烦了罗里吧嗦一大堆 那么有没有一种办法能简化ffmpeg的SDK调用过程呢既能解决重连的问题又能解决SDK纷繁复杂的调用过程问题而且还有整个过程中对音视频编码判断和重编码跳过的流程 有看看EasyAVFilter怎么完成这项工作 #include stdlib.h #include stdio.h #include string.h #include EasyAVFilterAPI.h#ifdef _WIN32 #pragma comment(lib,EasyAVFilter.lib) #endif int Easy_APICALL __AVFilterCallBack(void* userPtr, EASY_AV_FILTER_STATE_T status, int progress, int errCode, const char *errMsg) {return 0; }int main(int argc, char** argv) {//创建ffmpeg实例Easy_Handle avFilterHandle NULL;EasyAVFilter_Create(avFilterHandle);//设置回调函数获取回调信息EasyAVFilter_SetCallback(avFilterHandle,__AVFilterCallBack,0);//将RTSP流转成RTMP流EasyAVFilter_AddInput(avFilterHandle, rtsp://admin:admin112.112.112.212:554/ch1/main/av_stream, 1);EasyAVFilter_AddFilter(avFilterHandle, -vcodec copy -acodec aac -ac 2 -strict -2);EasyAVFilter_AddFilter(avFilterHandle, -f flv);EasyAVFilter_SetOutput(avFilterHandle, rtmp://172.81.216.155:13519/live/IbMkUXeVR?signSxMk8X6VRz, 0);//验证参数设置是否正确char filterCommand[256] { 0 };EasyAVFilter_GetFilters(avFilterHandle, filterCommand);printf(command: %s\n, filterCommand);//开始RTSP转RTMP工作EasyAVFilter_Start(avFilterHandle, 0, 8, 10);//注意文件转码不需要循环读取第二个参数从1改成0getchar();EasyAVFilter_Stop(avFilterHandle);EasyAVFilter_Release(avFilterHandle);return 0; }就上面八九个方法还包括了创建实例和停止/销毁实例核心方法就五六个就搞定了全部ffmpeg.exe所有的功能还能支持重连 方法名称说明EasyAVFilter_Create创建句柄相当于创建了一个ffmpeg.exeEasyAVFilter_Release释放句柄EasyAVFilter_SetCallback设置回调函数和自定义指针回调过程中的各种媒体信息/连接信息/转码进度EasyAVFilter_AddInput添加输入参数(源地址)EasyAVFilter_AddFilter添加中间参数,如:转码兼容ffmpeg命令所有参数例如-vcodec copy -acodec aacEasyAVFilter_SetOutput设置输出参数(目标地址) 支持默认转码H.264和自动根据源编码进行转码EasyAVFilter_GetFilters获取所有参数review参数输入是否正确EasyAVFilter_Start开始工作支持0次重连和N次重连EasyAVFilter_Stop停止工作 详细信息可以直接看https://www.easydarwin.org/tools/153.html具体用法和场景看视频介绍
http://www.sadfv.cn/news/366101/

相关文章:

  • 泰安营销网站建设公司番禺区建设局网站
  • 求职招聘网站开发重庆工程项目
  • 专业制作外贸网站网站详情页怎么做
  • UE4做购物网站物联网概念
  • 德州网站建设费用手机网站大全排行
  • 做网站排行前端网站开发流程图
  • html5公司手机网站模板那个网站做图片好看的
  • 新网站没有死链接怎么做深圳网站建设简介
  • 马鞍山做网站公司网络营销推广与策划实训总结
  • 汕头网站备案成都金牛区建设局网站
  • 51的网站是啥域名注册的网站都有哪些
  • 网站快速优化排名排名广州建设信息网官网
  • 上海做网站hlanggroup网上买保险网站
  • 在网络上做兼职的网站建筑图纸
  • 邯郸网站建设邯郸网站制作深圳网站建设 设计贝尔利
  • 网站做外链是什么意思网络营销的主要特点
  • 云南微网站建设免费推广引流平台
  • 郑州汉狮专业做网站公司网站运营每天做啥工作
  • 企业建站系统价格建设招标网是什么网站
  • 深圳网站建设哪家口碑好小程序爱成毅的微博
  • 湖北商城网站建设建设工程协会网站
  • 如何给网站做备案注册一个公司全部流程
  • 大连网站建设#选领超科技博客内容跟网站相关吗
  • 网站建设怎么做帐做网站都需要什么资料
  • 苏州网站建设网络国外免费域名注册平台
  • xp 做网站服务器吗校园网站建设管理制度
  • 本人承接网站建设wordpress仿站难吗
  • 六安网站制作费用多少网站转化率
  • 网站备案为什么 没有批复文件一下成都网站建设公司
  • 里水九江网站建设wordpress模板 单栏