Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goldplay播放相机(H.265)视频 #70

Open
zhujiarun opened this issue Sep 1, 2021 · 4 comments
Open

goldplay播放相机(H.265)视频 #70

zhujiarun opened this issue Sep 1, 2021 · 4 comments

Comments

@zhujiarun
Copy link

相机视频格式调成了H.265,并且将rtsp转成http(没有啥编解码只是换了一下头)。然后就放不出视频,想请教一下是需要什么其他设置吗

@yiwen03
Copy link
Contributor

yiwen03 commented Sep 1, 2021 via email

@zhujiarun
Copy link
Author

zhujiarun commented Sep 2, 2021

这是自己创建的rtmp的name
rtspLoad:是一个uuid
let rtmpName = rtmp://${this.nginxIp}:1935/cloubox_07/${rtspLoad};
然后用fluent-ffmpeg启动ffmpeg
//启动ffmpeg
startFfmpeg(camera_rtsp, rtmpName) {
try {
return new Promise((resolve, reject) => {
let command = ffmpeg();
command.input(camera_rtsp);
command.inputOptions("-stimeout 5000000");
command.inputOptions("-rtsp_transport tcp");
command.outputOptions("-max_muxing_queue_size 1024");
command.audioCodec('aac');
command.videoCodec("copy");
command.on("start", () => {});
command.on("codecData", () => {resolve(1);});
command.on("error", (err) => {reject(err); });
command.on('end', (stdout, stderr) => { });
command.format("flv");
command.save(rtmpName);
});
} catch (error) {
Logger.error("start ffmpeg failed!!!!",new Error(error));
}
}
最后用上方的rtspLoad构建一个http
httpName = http://${this.nginxIp}:${key}/stream?port=1935&app=cloubox_07&stream=${rtspLoad};

@yourchanges
Copy link

现在的实现有问题 不支持动态生成的hls协议的 .m3u8

如下面的命令:

ffmpeg -fflags genpts -rtsp_transport tcp \
	-i rtsp://xxx:yy@xxx.xxx.com:554/Streaming/Channels/1201 \
	-c:v copy -c:a copy -s 1920x1080  -f hls -hls_segment_type mpegts -hls_time 4 -hls_list_size 3 \
	-hls_flags delete_segments+append_list+split_by_time   ./rtsp/out.m3u8

那么 out.m3u8

就是

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:281
#EXTINF:4.000000,
out281.ts
#EXTINF:3.840000,
out282.ts
#EXTINF:4.120000,
out283.ts

这个m3u8 每3个新的ts 文件生成 就会变一下内容, 靠EXT-X-MEDIA-SEQUENCE 找到第一个, 播放完 就再加载一次m3u8. 没有 #EXT-X-ENDLIST 结束, 因为是实时直播流 不会结束

@yourchanges
Copy link

可以看看hls.js 对 播放列表的处理, 视频内容应该是正常播放的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants