海康摄像头抓图
curl –insecure –anyauth -u admin:password -X GET http://admin:password@192.168.110.19/ISAPI/Streaming/channels/110/picture >d:/b.jpg

海康RTSP流
rtsp://admin:password@192.168.110.19:554/Streaming/Channels/201

ffmpeg压缩海康录像文件 压缩率大概 15%
ffmpeg -i Downtest_ch0001_00000003678000000.mp4 -c:v libx264 -crf 28 -preset veryfast -c:a copy -movflags +faststart output.mp4 -y

JS Video截图上传代码

// 视频绘制canvas画布、截图上传
function canvasUpload() {
    let v = $(\'video\')[0];
    let canvas = document.createElement("canvas");
    canvas.width = v.videoWidth;
    canvas.height = v.videoHeight;
    let ctx = canvas.getContext("2d");
    ctx.drawImage(v, 0, 0, canvas.width, canvas.height);
    // document.body.appendChild(canvas);
    let imgSrc = canvas.toDataURL("image/jpeg", 0.8);
    $(\'#img1\').prop(\'src\', imgSrc);


    //获取裁剪完后的base64图片url,转换为blob
    var data = imgSrc;
    var formData = new FormData();
    formData.append("img_file", dataURLtoBlob(data));
    var httprequest = null;
    if (window.XMLHttpRequest) {
        httprequest = new XMLHttpRequest();
    } else {
        httprequest = new ActiveXObject(\'MicroSoft.XMLHTTP\');
    }
    var apiurl = "save.php?sn=" + $(\'#txtSn\').val(); //上传图片的api接口,自行填写
    httprequest.open(\'POST\', apiurl, true);
    httprequest.send(formData);
    httprequest.onreadystatechange = function () {
        if (httprequest.readyState == 4) {
            if (httprequest.status == 200) {
                console.log(\'上传成功\');
            }
            else {
                console.error(\'获取数据错误,错误代码:\' + httprequest.status + \'错误信息:\' + httprequest.statusText);
            }
        }
    };
}

//把base64位的toDataURL图片转换成blob
function dataURLtoBlob(dataurl) {
    var arr = dataurl.split(\',\'), mime = arr[0].match(/:(.*?);/)[1],
        bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
    while (n--) {
        u8arr[n] = bstr.charCodeAt(n);
    }
    return new Blob([u8arr], { type: mime });
}

 

版权声明:本文为zjfree原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/zjfree/p/13705082.html