package com.java110.gateway.sip.remux;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacv.FFmpegFrameRecorder;
import org.bytedeco.javacv.FFmpegLockCallback;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.FrameRecorder;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import static org.bytedeco.javacpp.avcodec.*;
import static org.bytedeco.javacpp.avdevice.avdevice_register_all;
import static org.bytedeco.javacpp.avformat.*;
import static org.bytedeco.javacpp.avutil.*;
import static org.bytedeco.javacpp.swresample.*;
import static org.bytedeco.javacpp.swscale.*;
/**
* 自定义FFmpegFrameRecorder
* 修改recordPacket函数,支持传入设置pts/dts
* @author yangjie
* 2020年3月23日
*/
@SuppressWarnings("all")
public class CustomFFmpegFrameRecorder extends FrameRecorder {
public static CustomFFmpegFrameRecorder createDefault(File f, int w, int h) throws Exception { return new CustomFFmpegFrameRecorder(f, w, h); }
public static CustomFFmpegFrameRecorder createDefault(String f, int w, int h) throws Exception { return new CustomFFmpegFrameRecorder(f, w, h); }
private static Exception loadingException = null;
public static void tryLoad() throws Exception {
if (loadingException != null) {
throw loadingException;
} else {
try {
Loader.load(org.bytedeco.javacpp.avutil.class);
Loader.load(org.bytedeco.javacpp.swresample.class);
Loader.load(org.bytedeco.javacpp.avcodec.class);
Loader.load(org.bytedeco.javacpp.avformat.class);
Loader.load(org.bytedeco.javacpp.swscale.class);
/* initialize libavcodec, and register all codecs and formats */
av_jni_set_java_vm(Loader.getJavaVM(), null);
avcodec_register_all();
av_register_all();
avformat_network_init();
Loader.load(org.bytedeco.javacpp.avdevice.class);
avdevice_register_all();
} catch (Throwable t) {
if (t instanceof Exception) {
throw loadingException = (Exception)t;
} else {
throw loadingException = new Exception("Failed to load " + FFmpegFrameRecorder.class, t);
}
}
}
}
static {
try {
tryLoad();
FFmpegLockCallback.init();
} catch (Exception ex) { }
}
public CustomFFmpegFrameRecorder(File file, int audioChannels) {
this(file, 0, 0, audioChannels);
}
public CustomFFmpegFrameRecorder(String filename, int audioChannels) {
this(filename, 0, 0, audioChannels);
}
public CustomFFmpegFrameRecorder(File file, int imageWidth, int imageHeight) {
this(file, imageWidth, imageHeight, 0);
}
public CustomFFmpegFrameRecorder(String filename, int imageWidth, int imageHeight) {
this(filename, imageWidth, imageHeight, 0);
}
public CustomFFmpegFrameRecorder(File file, int imageWidth, int imageHeight, int audioChannels) {
this(file.getAbsolutePath(), imageWidth, imageHeight, audioChannels);
}
public CustomFFmpegFrameRecorder(String filename, int imageWidth, int imageHeight, int audioChannels) {
this.filename = filename;
this.imageWidth = imageWidth;
this.imageHeight = imageHeight;
this.audioChannels = audioChannels;
this.pixelFormat = AV_PIX_FMT_NONE;
this.videoCodec = AV_CODEC_ID_NONE;
this.videoBitrate = 400000;
this.frameRate = 30;
this.sampleFormat = AV_SAMPLE_FMT_NONE;
this.audioCodec = AV_CODEC_ID_NONE;
this.audioBitrate = 64000;
this.sampleRate = 44100;
this.interleaved = true;
this.video_pkt = new AVPacket();
this.audio_pkt = new AVPacket();
}
public CustomFFmpegFrameRecorder(OutputStream outputStream, int audioChannels) {
this(outputStream.toString(), audioChannels);
this.outputStream = outputStream;
}
public CustomFFmpegFrameRecorder(OutputStream outputStream, int imageWidth, int imageHeight) {
this(outputStream.toString(), imageWidth, imageHeight);
this.outputStream = outputStream;
}
public CustomFFmpegFrameRecorder(OutputStream outputStream, int imageWidth, int imageHeight, int audioChannels) {
this(outputStream.toString(), imageWidth, imageHeight, audioChannels);
this.outputStream = outputStream;
}
public void release() throws Exception {
// synchronized (org.bytedeco.javacpp.avcodec.class) {
releaseUnsafe();
// }
}
void releaseUnsafe() throws Exception {
/* close each codec */
if (video_c != null) {
avcodec_free_context(video_c);
video_c = null;
}
if (audio_c != null) {
avcodec_free_context(audio_c);
audio_c = null;
}
if (picture_buf != null) {
av_free(picture_buf);
picture_buf = null;
}
if (picture != null) {
av_frame_free(picture);
picture = null;
}
if (tmp_picture != null) {
av_frame_free(tmp_picture);
tmp_picture = null;
}
if (video_outbuf != null) {
av_free(video_outbuf);
video_outbuf = null;
}
if (frame != null) {
av_frame_free(frame);
frame = null;
}
if (samples_out != null) {
for (int i = 0; i < samples_out.length; i++) {
av_free(samples_out[i].position(0));
}
samples_out = null;
}
if (audio_outbuf != null) {
av_free(audio_outbuf);
audio_outbuf = null;
}
if (video_st != null && video_st.metadata() != null) {
av_dict_free(video_st.metadata());
video_st.metadata(null);
}
if (audio_st != null && audio_st.metadata() != null) {
av_dict_free(audio_st.metadata());
audio_st.metadata(null);
}
video_st = null;
audio_st = null;
filename = null;
AVFormatContext outputStreamKey = oc;
if (oc != null && !oc.isNull()) {
if (outputStream == null && (oformat.flags() & AVFMT_NOFILE) == 0) {
/* close the output file */
avio_close(oc.pb());
}
/* free the streams */
int nb_streams = oc.nb_streams();
for(int i = 0; i < nb_streams; i++) {
av_free(oc.streams(i).codec());
av_free(oc.streams(i));
}
/* free metadata */
if (oc.metadata() != null) {
av_dict_free(oc.metadata());
oc.metadata(null);
}
/* free the stream */
av_free(oc);
oc = null;
}
if (img_convert_ctx != null) {
sws_freeContext(img_convert_ctx);
img_convert_ctx = null;
}
if (samples_convert_ctx != null) {
swr_free(samples_convert_ctx);
samples_convert_ctx = null;
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException ex) {
throw new Exception("Error on OutputStream.close(): ", ex);
} finally {
outputStream = null;
outputStreams.remove(outputStreamKey);
if (avio != null) {
if (avio.buffer() != null) {
av_free(avio.buffer());
avio.buffer(null);
}
av_free(avio);
avio = null;
}
}
}
}
@Override protected void finalize() throws Throwable {
super.finalize();
release();
}
static Map<Pointer,OutputStream> outputStreams = Collections.synchronizedMap(new HashMap<Pointer,OutputStream>());
static class WriteCallback extends Write_packet_Pointer_BytePointer_int {
@Override public int call(Pointer opaque, BytePointer buf, int buf_size) {
try {
byte[] b = new byte[buf_size];
OutputStream os = outputStreams.get(opaque);
buf.get(b, 0, buf_size);
os.write(b, 0, buf_size);
return buf_size;
}
catch (Throwable t) {
System.err.println("Error on OutputStream.write(): " + t);
return -1;
}
}
}
static WriteCallback writeCallback = new WriteCallback();
static {
PointerScope s = PointerScope.getInnerScope();
if (s != null) {
s.detach(writeCallback);
}
}
private OutputStream outputStream;
private AVIOContext avio;
private String filename;
private AVFrame picture, tmp_picture;
private BytePointer picture_buf;
private BytePointer video_outbuf;
private int video_outbuf_size;
private AVFrame frame;
private Pointer[] samples_in;
private BytePointer[] samples_out;
private PointerPointer samples_in_ptr;
private PointerPointer samples_out_ptr;
private BytePointer audio_outbuf;
private int audio_outbuf_size;
private in
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
项目详情请参见:https://handsome-man.blog.csdn.net/article/details/129677572 本项目是一款前、后端社区道闸门禁和人员考勤物联网管理系统。 前端采用主流vue+elementui+admin,后端采用spring boot,项目架构简单,容易对接自己的硬件。 项目主要包括:小区管理、门禁管理、道闸管理、云考勤管理、组织信息和系统设置6部分功能。 项目代码可直接编译运行~
资源推荐
资源详情
资源评论
收起资源包目录
社区闸道门禁和考勤物联网管理系统【毕业设计、课程设计】 (972个子文件)
index.html.bak 1KB
index.html.bak 1KB
chunk-elementUI.ded27da0.css 228KB
vxgplayer-1.8.40.min.css 101KB
vxgplayer-1.8.40.min.css 101KB
app.7d6645bb.css 9KB
app.81a3d272.css 9KB
app.fbf42e2f.css 9KB
chunk-68697b0f.5e9c0b21.css 5KB
chunk-libs.3dfb7769.css 3KB
chunk-2bdf02c5.972fad9d.css 2KB
chunk-17f4c550.d6c5168f.css 2KB
chunk-999e921a.5781f851.css 2KB
chunk-0b82ae90.ca1c5401.css 2KB
chunk-34ac9bda.40f76b5c.css 132B
chunk-022fe339.c2ac5852.css 132B
chunk-7e1db451.40f76b5c.css 132B
chunk-6827938e.c2ac5852.css 132B
chunk-5c46c9b6.40f76b5c.css 132B
chunk-35616ac6.40f76b5c.css 132B
chunk-af05ada8.40f76b5c.css 132B
chunk-7de47e8a.c2ac5852.css 132B
chunk-23fc23da.40f76b5c.css 132B
chunk-075604fe.c2ac5852.css 132B
chunk-61340210.40f76b5c.css 132B
chunk-0f794c68.c2ac5852.css 132B
chunk-704edafa.c2ac5852.css 132B
chunk-77c25c43.c2ac5852.css 132B
chunk-1de6aa31.40f76b5c.css 132B
chunk-8a65f9c2.c2ac5852.css 132B
chunk-1663e808.c2ac5852.css 132B
chunk-cfe760a8.c2ac5852.css 132B
chunk-62d1d5bc.40f76b5c.css 132B
chunk-d22bea7e.40f76b5c.css 132B
chunk-7797e191.c2ac5852.css 132B
chunk-3ecc599a.40f76b5c.css 132B
chunk-3e530e54.c2ac5852.css 132B
chunk-a25b7d56.c2ac5852.css 132B
chunk-6397242a.c2ac5852.css 132B
chunk-3877325e.40f76b5c.css 132B
chunk-0221e498.c2ac5852.css 132B
chunk-627de5f9.40f76b5c.css 132B
chunk-332134ea.40f76b5c.css 132B
chunk-2f86ad35.c2ac5852.css 132B
chunk-e8f69e96.40f76b5c.css 132B
chunk-32acad60.c2ac5852.css 132B
chunk-f54ddbda.40f76b5c.css 132B
chunk-adc4ecf4.40f76b5c.css 132B
chunk-110fb03c.c2ac5852.css 132B
chunk-498ba473.c2ac5852.css 132B
chunk-14e3a858.40f76b5c.css 132B
chunk-6c8403d5.40f76b5c.css 132B
chunk-46b8e918.c2ac5852.css 132B
chunk-a6a9c39e.c2ac5852.css 132B
chunk-4b886cc6.c2ac5852.css 132B
chunk-010290e4.c2ac5852.css 132B
chunk-7add0928.40f76b5c.css 132B
chunk-4c3b32b6.40f76b5c.css 132B
chunk-a0f1df7e.c2ac5852.css 132B
chunk-3cb720e7.c2ac5852.css 132B
chunk-df7f277a.c2ac5852.css 132B
chunk-a5724b36.c2ac5852.css 132B
chunk-25ace5c4.40f76b5c.css 132B
chunk-40a75da4.40f76b5c.css 132B
chunk-8ca09a68.c2ac5852.css 132B
chunk-5dea0c4c.c2ac5852.css 132B
chunk-1958b724.c2ac5852.css 132B
chunk-46110992.c2ac5852.css 132B
chunk-1ec4bd0e.c2ac5852.css 132B
chunk-4c0240a0.c2ac5852.css 132B
chunk-66f5d3ae.40f76b5c.css 132B
chunk-792dfef3.40f76b5c.css 132B
chunk-46aabba4.c2ac5852.css 132B
chunk-328578b6.40f76b5c.css 132B
chunk-23432f01.c2ac5852.css 132B
chunk-161ac6c8.40f76b5c.css 132B
chunk-953df08c.40f76b5c.css 132B
chunk-05aa5630.c2ac5852.css 132B
chunk-05c9113b.256da67a.css 115B
chunk-364c470a.6fd37633.css 115B
chunk-27075535.019d7e24.css 115B
.env.development 534B
.editorconfig 243B
eeee 3KB
.eslintignore 34B
.gitignore 190B
index.html 6KB
video3.html 2KB
video3.html 2KB
video.html 875B
video.html 875B
index.html 662B
video1.html 507B
video1.html 507B
video.html 491B
favicon.ico 1KB
favicon.ico 1KB
tdx-face-sdk-1.2.2.jar 97KB
CustomFFmpegFrameRecorder.java 44KB
TaogesiCarSocketProcessAdapt.java 33KB
共 972 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
不脱发的程序猿
- 粉丝: 24w+
- 资源: 5782
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功