代码拉取完成,页面将自动刷新
同步操作将从 Oscura/iot-communication 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
public class RtspTcpAuthenticator {
public static void main(String[] args) {
// rtsp的摄像头地址
URI uri = URI.create("rtsp://192.168.3.1:554/h264/ch1/main/av_stream");
// 身份认证
UsernamePasswordCredential credential = new UsernamePasswordCredential("admin", "123456");
DigestAuthenticator authenticator = new DigestAuthenticator(credential);
// 构建RTSP客户端对象
RtspClient client = new RtspClient(uri, authenticator);
// 设置RTSP交互过程信息打印,若不需要则可以不设置
client.onCommCallback(System.out::println);
// 设置接收的视频数据帧事件
client.onFrameHandle(x -> {
H264VideoFrame f = (H264VideoFrame) x;
System.out.println(f.getFrameType() + ", " + f.getNaluType() + ", " + f.getTimestamp() + ", " + f.getFrameSegment().length);
});
client.onDestroyHandle(() -> System.out.println("close"));
// 采用异步的形式关闭,由于是测试示例,写在启动前面
CompletableFuture.runAsync(() -> {
try {
TimeUnit.SECONDS.sleep(3);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
client.stop();
});
// 启动,返回异步执行对象
CompletableFuture<Void> future = client.start();
// 循环等待结束
while (!future.isDone()) {
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
}
public class DemoFMp4 {
public static void main(String[] args) {
List<Mp4SampleData> samples = new ArrayList<>();
Mp4SampleData data = new Mp4SampleData();
data.setTimestamp(System.currentTimeMillis());
data.setData(new byte[5459]);
data.setDuration(3600);
data.setCts(0);
Mp4SampleFlag flag = new Mp4SampleFlag();
flag.setDependedOn(2);
data.setFlags(flag);
samples.add(data);
Mp4TrackInfo trackInfo = new Mp4TrackInfo();
trackInfo.setId(1);
trackInfo.setType("video");
trackInfo.setTimescale(90000);
trackInfo.setDuration(90000);
trackInfo.setWidth(1920);
trackInfo.setHeight(1080);
trackInfo.setSps(new byte[]{0x67, 0x64, 0x00, 0x2A, (byte) 0xAC, 0x2B, 0x50, 0x3C, 0x01, 0x13, (byte) 0xF2, (byte) 0xCD, (byte) 0xC0, 0x40, 0x40, 0x40, (byte) 0x80});
trackInfo.setPps(new byte[]{0x68, (byte) 0xEE, 0x3C, (byte) 0xB0});
trackInfo.setSampleData(samples);
Mp4Header mp4FtypMoov = new Mp4Header(trackInfo);
Mp4SampleData first = trackInfo.getSampleData().get(0);
Mp4MoofBox mp4MoofBox = new Mp4MoofBox(1, first.getTimestamp(), trackInfo);
Mp4MdatBox mp4MdatBox = new Mp4MdatBox(trackInfo.totalSampleData());
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。