GithubHelp home page GithubHelp logo

eguid / easycv Goto Github PK

View Code? Open in Web Editor NEW
174.0 13.0 101.0 334 KB

easyCV (video recorder and snapshot library,based on javaCV)基于javaCV的跨平台视频录像和基于FFmpeg的快照(截图)库

Home Page: https://blog.csdn.net/eguid_1/article/details/83345489

License: Apache License 2.0

Java 100.00%
javacv video screenshot videosnapshot recorder easycv base64

easycv's People

Contributors

dependabot[bot] avatar eguid avatar lasttaoist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easycv's Issues

运行的时候报以下错误,是还需要安装单独的数据库吗?


APPLICATION FAILED TO START


Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

Action:

Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

关于录像服务。

看了下代码,这个录像服务是对视频文件进行转录么?
不是进行本地的屏幕录像?并没有找到对应代码。

请问,通过recordPacket对mp4文件进行hls切片,切片后ts文件数量正常,但是m3u8文件里每片的时长不对

hls切片时间设置的是5s,一个29s的mp4视频,切片后,切片数量是5 正常,也能正常播放,但是m3u8文件里每片时长只有1s左右,导致播放器显示的总时长不对:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:1
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:0.766667,
out0.ts
#EXTINF:0.644444,
out1.ts
#EXTINF:1.016667,
out2.ts
#EXTINF:0.416667,
out3.ts
#EXTINF:1.288889,
out4.ts
#EXT-X-ENDLIST

以下是代码
`public static void packetRecord(String inputFile, String outputFile) throws FrameGrabber.Exception, FrameRecorder.Exception {

    FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(inputFile);
    FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(outputFile, 1280, 720, 2);

    grabber.start();
    
    recorder.setOption("hls_list_size", "0");
    recorder.setOption("hls_time", "5");
    recorder.start(grabber.getFormatContext());

    AVPacket packet;

    while ((packet = grabber.grabPacket()) != null) {
        recorder.recordPacket(packet);

    }

    recorder.stop();
    grabber.stop();
}`

packetRecord("F:\\beixiyan.mp4","out.m3u8");

请问该如何避免该问题,万分感谢

初始化比较慢

我这用GrabberTemplate4截图的时候,发现初始化步骤耗时是整个截图周期最长的一段,截图耗时1s多,单是
if(!initGrabber(url,fmt)) { return null; }
就要耗时1s,这个初始化操作能不能移到服务启动的时候进行初始化,然后在服务关闭的时候
进行以下释放操作?
av_free(buffer); freeAndClose();

接入hls协议视频流截图时,截图出现了全黑图片,请问这是视频源网络不稳定造成的,还是其他原因呢?您这边是否有解决方案呢?另外,debug跟踪代码时,发现在打开视频源时,接入的视频流长度只有2,如何更改这个长度呢?

/**
 * 打开视频流
 * @param url -url
 * @return
 * @throws FileNotOpenException
 */
protected avformat.AVFormatContext openInput(String url) throws FileNotOpenException {

	avformat.AVFormatContext pFormatCtx = new avformat.AVFormatContext(null);
    int length = pFormatCtx.nb_streams();//这里为何一直时固定值2,如何更改此处值呢?
    if(avformat_open_input(pFormatCtx, url, null, null)==0) {
		return pFormatCtx;
	}
	throw new FileNotOpenException("Didn't open video file");
}

ubuntu下运行报错

我在mac下运行可以正常得到截图,在Ubuntu下报错,mac中ffmpeg版本为
ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
ubuntu中版本为:
ffmpeg version 4.2-0york0~18.04 Copyright (c) 2000-2019 the FFmpeg developers

Ubuntu中的报错为:
[rtsp @ 0x7f2be4122d40] method PAUSE failed: 551 Option not supported
[hevc @ 0x7f2be411ea00] missing picture in access unit
[IMGUTILS @ 0x7f2c50530040] Picture size 0x0 is invalid
Assertion desc failed at libswscale/swscale_internal.h:668

请问这是什么原因?

非正常情况导致读流出错,从而影响线程计数,如rtsp流异常关闭会导致线程不可用

大神你好,mainloop 方法里面貌似存在问题,当抓流器不能正常访问到rtsp流时, 方法进入catch 模块, 状态会被置为 STOP_STATUS 停止状态,线程的下一次for 循环会根据 status 状态让线程 执行wait(),线程进入等候状态,而此时当前线程所对应的task 并没有从workpool 移动到idlepool 中, 导致计数不对,当线程耗尽则 无法开启新的任务。

`/**
* 核心转换处理循环
*/
private void mainLoop() {
long startime=System.currentTimeMillis();
long err_index = 0;//采集或推流失败次数
long frame_index=0;
int pause_num=0;//暂停次数
try {
for(;status==START_STATUS;frame_index++) {
Frame pkt=grabber.grabFrame();
if(pause==1) {//暂停状态
pause_num++;
continue;
}
if(pkt==null) {//采集空包结束
if(err_index>err_stop_num) {//超过三次则终止录制
System.err.println(getName()+"工作线程采集视频帧连续"+err_index+"次空包,本次任务终止");
break;
}
err_index++;
continue;
}
record.record(pkt);
}
}catch (Exception e) {//推流失败
status=STOP_STATUS;//到这里表示已经停止了
System.err.println("异常导致停止录像,详情:"+e.getMessage());
}finally {

		//此处没有对线程池中的workpool 池中的任务移动到idepool中,导致计数错误
		status=STOP_STATUS;
		stopRecord();
		System.out.println(getName()+"工作线程的录像任务已结束,持续时长:"+(System.currentTimeMillis()-startime)/1000+"秒,共录制:"+frame_index+"帧,遇到的错误数:"+err_index+",录制期间共暂停次数:"+pause_num);
	}
}

exception 后 下一次for循环 线程进入等候状态,没有对线程池中的workpool 池中的任务移动到idepool中,导致计数错误

`@Override
public void run() {
go();
for(;;) {
if(status==2) {
System.out.println("工作线程进入等待状态");
synchronized (this){
try {
wait();
}catch(InterruptedException e) {
}
}
System.out.println("工作线程唤醒");
continue;
}
//核心任务循环
mainLoop();
}
}

//exception 后 下一次for循环 线程进入等候状态,没有对线程池中的workpool 池中的任务移动到
//idepool中,导致计数错误

@OverRide
public void run() {
go();
for(;;) {
if(status==2) {
System.out.println("工作线程进入等待状态");
synchronized (this){
try {
wait();
}catch(InterruptedException e) {
}
}
System.out.println("工作线程唤醒");
continue;
}
//核心任务循环
mainLoop();
}
}`

关于JavaImgConverter中的一个bug

JavaImgConverter.java这个类的第164行的BGR2BufferedImage方法

public static BufferedImage BGR2BufferedImage(byte[] src,int width,int height) {
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);

    Raster ra = image.getRaster();
    DataBuffer out = ra.getDataBuffer();
    DataBufferByte db=(DataBufferByte)out;
    ByteBuffer.wrap(db.getData()).put(src,0,src.length);
    // 这里应该要一行 image.setData(raster);  不然image里的图像数据不会发生改变
    return image;
}

Question about FPS

As I use your code, the fps is 0.5/s. I want to change the FPS, but it didn't work. Can you give me some advice?

编译问题

master 分支
maven-compiler-plugin executable 一般都配置的 JAVA_HOME ,应该很少配置 JAVA8_HOME
videoRecorder 的 parent 的 groupId 好像有问题吧 ? cc.eguid.cv.easyCV 应该是 cc.eguid.cv.corelib ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.