在使用MediaRecorder API的录制视频中寻找不起作用

时间:2018-05-29 14:15:09

标签: javascript screen-recording web-mediarecorder mediarecorder-api

我正在尝试使用MediaRecorder API构建屏幕录制。

作为暗示性媒体记录方法

2018-05-29 21:42:07,913 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 67) WFLYUT0021: Registered web context: '/kie-server-controller-standalone-7.7.0.Final-ee7' for server 'default-server'
2018-05-29 21:42:20,751 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0059: Class Path entry jaxb-api.jar in /C:/Users/jerem/Downloads/wildfly-11.0.0.Final/bin/content/kie-server-7.7.0.Final-ee7.war/WEB-INF/lib/jaxb-core-2.2.11.jar  does not point to a valid jar for a Class-Path reference.
2018-05-29 21:42:20,754 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0059: Class Path entry jaxb-core.jar in /C:/Users/jerem/Downloads/wildfly-11.0.0.Final/bin/content/kie-server-7.7.0.Final-ee7.war/WEB-INF/lib/jaxb-impl-2.2.11.jar  does not point to a valid jar for a Class-Path reference.
2018-05-29 21:42:20,816 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0059: Class Path entry xml-apis.jar in /C:/Users/jerem/Downloads/wildfly-11.0.0.Final/bin/content/kie-server-7.7.0.Final-ee7.war/WEB-INF/lib/serializer-2.7.1.jar  does not point to a valid jar for a Class-Path reference.
2018-05-29 21:42:20,822 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0059: Class Path entry xercesImpl.jar in /C:/Users/jerem/Downloads/wildfly-11.0.0.Final/bin/content/kie-server-7.7.0.Final-ee7.war/WEB-INF/lib/xalan-2.7.1.jar  does not point to a valid jar for a Class-Path reference.
2018-05-29 21:42:20,822 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0059: Class Path entry xml-apis.jar in /C:/Users/jerem/Downloads/wildfly-11.0.0.Final/bin/content/kie-server-7.7.0.Final-ee7.war/WEB-INF/lib/xalan-2.7.1.jar  does not point to a valid jar for a Class-Path reference.
2018-05-29 21:42:20,822 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0059: Class Path entry serializer.jar in /C:/Users/jerem/Downloads/wildfly-11.0.0.Final/bin/content/kie-server-7.7.0.Final-ee7.war/WEB-INF/lib/xalan-2.7.1.jar  does not point to a valid jar for a Class-Path reference.
2018-05-29 21:42:20,847 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.deployment.unit."kie-server-7.7.0.Final-ee7.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."kie-server-7.7.0.Final-ee7.war".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment "kie-server-7.7.0.Final-ee7.war"
    at org.jboss.as.server//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
    at org.jboss.msc//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
    at org.jboss.msc//org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: org.jboss.msc.service.ServiceNotFoundException: Service service jboss.ejb.default-resource-adapter-name-service not found
    at org.jboss.msc//org.jboss.msc.service.ServiceContainerImpl.getRequiredService(ServiceContainerImpl.java:669)
    at org.jboss.as.ejb3//org.jboss.as.ejb3.deployment.processors.MessageDrivenComponentDescriptionFactory.getDefaultResourceAdapterName(MessageDrivenComponentDescriptionFactory.java:274)
    at org.jboss.as.ejb3//org.jboss.as.ejb3.deployment.processors.MessageDrivenComponentDescriptionFactory.processMessageBeans(MessageDrivenComponentDescriptionFactory.java:154)
    at org.jboss.as.ejb3//org.jboss.as.ejb3.deployment.processors.MessageDrivenComponentDescriptionFactory.processAnnotations(MessageDrivenComponentDescriptionFactory.java:81)
    at org.jboss.as.ejb3//org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.processAnnotations(AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.java:57)
    at org.jboss.as.ejb3//org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.deploy(AbstractDeploymentUnitProcessor.java:76)
    at org.jboss.as.server//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
    ... 5 more

2018-05-29 21:42:20,851 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "kie-server-7.7.0.Final-ee7.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"kie-server-7.7.0.Final-ee7.war\".PARSE" => "WFLYSRV0153: Failed to process phase PARSE of deployment \"kie-server-7.7.0.Final-ee7.war\"
    Caused by: org.jboss.msc.service.ServiceNotFoundException: Service service jboss.ejb.default-resource-adapter-name-service not found"}}
2018-05-29 21:42:20,868 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 37) WFLYSRV0010: Deployed "kie-server-router-proxy-7.7.0.Final.jar" (runtime-name : "kie-server-router-proxy-7.7.0.Final.jar")
2018-05-29 21:42:20,870 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 37) WFLYSRV0010: Deployed "kie-server-controller-standalone-7.7.0.Final-ee7.war" (runtime-name : "kie-server-controller-standalone-7.7.0.Final-ee7.war")
2018-05-29 21:42:20,870 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 37) WFLYSRV0010: Deployed "kie-server-7.7.0.Final-ee7.war" (runtime-name : "kie-server-7.7.0.Final-ee7.war")
2018-05-29 21:42:20,874 INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186:   Services which failed to start:      service jboss.deployment.unit."kie-server-7.7.0.Final-ee7.war".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment "kie-server-7.7.0.Final-ee7.war"

2018-05-29 21:42:20,947 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
2018-05-29 21:42:20,950 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
2018-05-29 21:42:20,952 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
2018-05-29 21:42:20,953 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 11.0.0.Final (WildFly Core 3.0.8.Final) started (with errors) in 28119ms - Started 450 of 680 services (1 services failed or missing dependencies, 356 services are lazy, passive or on-demand)

使用这种方法录制工作正常,但录制的视频搜索无效。

我在网上搜索过这个问题,我发现视频标题不包含持续时间。

在控制台上打印var chunks = []; var recorder = new MediaRecorder(stream); recorder.streams = [stream]; recorder.ondataavailable = function(e) { chunks.push(e.data); }; recorder.onstop = function(){ var blob = new Blob(chunks, {type: "video/webm"}); chunks = []; var mimeType = 'video/webm'; var fileExtension = 'webm'; var file = new File([blob ? blob : ''], getFileName(fileExtension), { type: mimeType }); }; 对象时,它包含以下属性

file

可以看到文件对象不包含持续时间属性。

有人可以建议任何可用的javascript库,只有在准备视频文件时才能在客户端修复视频标头吗?

2 个答案:

答案 0 :(得分:1)

https://recordrtc.org/ 处查看 getSeekableBlob

这是代码:

function getSeekableBlob(inputBlob, callback) {
    // EBML.js copyrights goes to: https://github.com/legokichi/ts-ebml
    if (typeof EBML === 'undefined') {
        throw new Error('Please link: https://cdn.webrtc-experiment.com/EBML.js');
    }
    var reader = new EBML.Reader();
    var decoder = new EBML.Decoder();
    var tools = EBML.tools;
    var fileReader = new FileReader();
    fileReader.onload = function(e) {
        var ebmlElms = decoder.decode(this.result);
        ebmlElms.forEach(function(element) {
            reader.read(element);
        });
        reader.stop();
        var refinedMetadataBuf = tools.makeMetadataSeekable(reader.metadatas, reader.duration, reader.cues);
        var body = this.result.slice(reader.metadataSize);
        var newBlob = new Blob([refinedMetadataBuf, body], {
            type: 'video/webm'
        });
        callback(newBlob);
    };
    fileReader.readAsArrayBuffer(inputBlob);
}

答案 1 :(得分:0)

这是Chrome中一个众所周知的错误。基本上,录制媒体的持续时间不会添加到最终文件的标题中。

遗憾的是,Chromium小组目前将此错误标记为WontFix。但是,有两种解决方法:

  • 在后端,使用ffmpeg修复标题:ffmpeg -i old.webm output.webm

  • 在前端,this answer上的解决方法或使用软件包ts-ebml