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

定制建站公司水果店推广营销方案

定制建站公司,水果店推广营销方案,邢台贴吧,wordpress国内免费模板简言&#xff1a;视频流格式大致分为&#xff1a;RTMP、RTSP、RTP、HLS、MPEG-DASH。 本文就只说一下Rtsp转Rtmp格式&#xff0c;转换成功之后Rtmp的视频流存储到srs上 Pom文件 <dependency><groupId>org.bytedeco</groupId><artifactId>javacv-platf…

简言:视频流格式大致分为:RTMP、RTSP、RTP、HLS、MPEG-DASH。
本文就只说一下Rtsp转Rtmp格式,转换成功之后Rtmp的视频流存储到srs上
Pom文件

<dependency><groupId>org.bytedeco</groupId><artifactId>javacv-platform</artifactId><version>1.5.1</version>
</dependency>

Constant类

public class Constant {public final static String rtmp="rtmp://";public final static String colon=":";public final static String slash="/";public final static String stop="stop";
}

application.properties

rtmp.host: 
rtmp.port: 
rtmp.folder: 

rtmp.host: srs安装的ip地址
rtmp.port: srs的端口
rtmp.folder:视频流存储的位置

具体实现

import org.bytedeco.ffmpeg.global.avcodec;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.FFmpegFrameRecorder;
import org.bytedeco.javacv.FFmpegLogCallback;
import org.bytedeco.javacv.Frame;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;/*** @author: majinzhong* @date: 2022/6/10 13:53* @Version 1.0*/
@RestController
@CrossOrigin
@RequestMapping("/stream")
public class CameraPushController {@Value("${rtmp.host}")public String rtmpHost;@Value("${rtmp.port}")public String rtmpPort;@Value("${rtmp.folder}")public String rtmpFolder;@RequestMapping("/info")public String info(){return "项目启动成功";}/**** @param rtsUrl rtsp的推流地址(在用户关闭时也要传值)* @param status 是否停止的状态(在用户关闭时传值,其他时候不传)* @return*/@RequestMapping("/push")public String streamPush(String rtsUrl,String status)throws Exception{//取出rtsUrl入参中的最后一个/后的streamIdString streamId = rtsUrl.substring(rtsUrl.lastIndexOf(Constant.slash) + 1);//对SRS的推流地址进行拼接String rtmpUrl = Constant.rtmp + rtmpHost + Constant.colon + rtmpPort + Constant.slash + rtmpFolder + Constant.slash + streamId;//实例化帧抓取器对象,将rtsp地址放入FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(rtsUrl);grabber.setOption("rtsp_transport", "tcp");//初始化帧抓取器grabber.start();//实例化FFmpegFrameRecorder,将SRS地址传入FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(rtmpUrl,grabber.getImageWidth() * 2,grabber.getImageHeight() * 2,grabber.getAudioChannels());int v_rs = 25;//设置编码格式recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);//设置封装格式recorder.setFormat("flv");//一秒内的帧数recorder.setFrameRate(v_rs);//两个关键帧之间的帧数recorder.setGopSize(v_rs);//设置音频通道,与视频源的通道数相等recorder.setAudioChannels(grabber.getAudioChannels());FFmpegLogCallback.set();//初始化帧录制器recorder.start();try {//使用异步线程让视频流 从rtsp转为rtmpif(!StringUtils.isEmpty(status)) {//获取当前所有在运行的线程ThreadGroup currentGroup =Thread.currentThread().getThreadGroup();int noThreads = currentGroup.activeCount();Thread[] lstThreads = new Thread[noThreads];currentGroup.enumerate(lstThreads);for (int i = 0; i < noThreads; i++){//找到视频流的线程if("push".equals(lstThreads[i].getName())){//让视频流线程睡眠1秒,因为在执行的线程不能直接结束lstThreads[i].sleep(1000);//结束线程,阻止推流lstThreads[i].suspend();}}//如果是停止就关闭录制器和抓取器并退出程序,如果是替换,就继续创建新线程推流if(Constant.stop.equals(status)) {//关闭帧录制器recorder.close();//关闭帧抓取器grabber.close();return "停止推流成功!";}}//创建新线程进行推流Thread thread = new Thread(() -> {try {//持续从视频源取帧Frame frame;while (null != (frame = grabber.grab())) {//取出的每一帧都推送到SRSrecorder.record(frame);}} catch (Exception e) {e.printStackTrace();}});//给线程设置名称,方便后续查找thread.setName("push");//启动线程thread.start();}catch (Exception e){e.printStackTrace();System.out.println(e);}return rtmpUrl;}
}


文章转载自:

http://PrYqaAxy.nnwpz.cn
http://iWvMVvh1.nnwpz.cn
http://DqnzR1KQ.nnwpz.cn
http://tUsdMB9e.nnwpz.cn
http://68zzQGUr.nnwpz.cn
http://8JtRdlkB.nnwpz.cn
http://3KKkkp3m.nnwpz.cn
http://OD7hk3ZU.nnwpz.cn
http://63WgQrfS.nnwpz.cn
http://W7fnQB3A.nnwpz.cn
http://ATvuWPcg.nnwpz.cn
http://ZKudDWr4.nnwpz.cn
http://4zcBHnlG.nnwpz.cn
http://zrXWCsXn.nnwpz.cn
http://3ziwe8Ww.nnwpz.cn
http://88lxUYaM.nnwpz.cn
http://7Ps41kS0.nnwpz.cn
http://pIBfZNfe.nnwpz.cn
http://BeGCXRtY.nnwpz.cn
http://c2lujHEu.nnwpz.cn
http://syVQMUJY.nnwpz.cn
http://4LNqeHY4.nnwpz.cn
http://dOAxqL7I.nnwpz.cn
http://VIkFZkul.nnwpz.cn
http://fwLfvFpt.nnwpz.cn
http://WTymoCn3.nnwpz.cn
http://kLafOeNP.nnwpz.cn
http://zzdtL9fd.nnwpz.cn
http://8NpkCGw1.nnwpz.cn
http://jaafoXil.nnwpz.cn
http://www.dtcms.com/wzjs/609162.html

相关文章:

  • win2003 做网站服务器哪些网站可以做问卷调查赚钱
  • 上海网站seo诊断长春设计网站
  • 附近做网站的公司电话浙江理工大学网站设计与建设
  • 全国企业系统网站建设新闻早知道
  • 对网站政务建设的建议口碑营销案例有哪些
  • 合肥做个网站多少钱优化关键词具体要怎么做
  • 宁波网站建设服务电话wordpress ping optimizer
  • 民宿网站开发dfd图模板中心
  • 公司网站免费模板推广文案怎么写
  • 优秀手机网站傻瓜式制作app的软件
  • wix如何做网站渝快办官网
  • eclipse开发网站开发服务称赞的建筑机电网
  • 国内无版权图片网站建筑模板公司
  • 重庆网站建设公司的网站跨境o2o网站建设方案
  • 生成flash的网站源码中文安卓开发工具
  • 汕头如何建设网站设计如何让网页适应屏幕尺寸
  • 手机网站 侧边栏导航网站滑动
  • 有没有专业做挂的网站吗北京附近做网站的公司有哪些
  • 邢台 网站建设建立什么填词语
  • 怎么自己做淘宝客网站ui培训学校哪家好
  • 电子商务网站策划书3000字城市之星福州网站建设
  • 整容网站模板wordpress如何修改背景图片
  • 昆明做网站win主机安装wordpress
  • 天津电子商务网站建设南阳平面设计培训学校
  • 社交网站 设计高级搜索引擎
  • 网络游戏公司排行榜前十名云南seo网站关键词优化软件
  • 在线做六级阅读网站徐州手机网站开发公司电话
  • o2o网站建设方案讲解如何做网站关键词词霸
  • 自学免费网站建设自己做的网站别人怎么访问
  • 基于网站开发app建设卒中中心几个网站