Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用OpenCV和gstreamer编写MP4文件,可在web浏览器(firefox/opera)中打开_Opencv_Gstreamer_Mp4 - Fatal编程技术网

使用OpenCV和gstreamer编写MP4文件,可在web浏览器(firefox/opera)中打开

使用OpenCV和gstreamer编写MP4文件,可在web浏览器(firefox/opera)中打开,opencv,gstreamer,mp4,Opencv,Gstreamer,Mp4,我正在尝试从IPCamera接收视频流,并希望编写可以在firefox/bouser中打开的视频mp4 以下工作将被罚款: gst-launch-1.0 -e rtspsrc location = rtsp://.... ! decodebin ! x264enc ! mp4mux ! filesink location=file.mp4$ 这个(file.mp4)文件我可以在firefox中打开 但当我从opencv写入文件时,我得到的是mp4视频文件,我可以在vlc中打开,但不能在br

我正在尝试从IPCamera接收视频流,并希望编写可以在firefox/bouser中打开的视频mp4

以下工作将被罚款:

  gst-launch-1.0 -e rtspsrc location = rtsp://.... ! decodebin ! x264enc ! mp4mux ! filesink location=file.mp4$
这个(file.mp4)文件我可以在firefox中打开

但当我从opencv写入文件时,我得到的是mp4视频文件,我可以在vlc中打开,但不能在brouser/firefox中打开:

    int main()
    {
        const char* gst = "rtspsrc location = rtsp://<ipcamera>  latency=0  ! rtph264depay ! avdec_h264 ! videoconvert ! appsink";
        const char*  gst_writer = "appsrc ! autovideoconvert ! x264enc ! mp4mux ! filesink location=test.mp4";
        cv::VideoCapture cap(gst);
        if (!cap.isOpened()) {
            std::cout << "Failed to open camera." << std::endl;
            return (-1);
        }
        unsigned int width = cap.get(CV_CAP_PROP_FRAME_WIDTH);
        unsigned int height = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
        unsigned int fps = cap.get(CV_CAP_PROP_FPS);
        unsigned int pixels = width * height;
        std::cout << " Frame size : " << width << " x " << height << ", " << pixels << " Pixels " << fps << " FPS" << std::endl;
        cv::VideoWriter writer(gst_writer, cap.get(CV_CAP_PROP_FOURCC), fps, cv::Size(width, height));
        if (!writer.isOpened()) {
            std::cout << "Failed to open writer." << std::endl;
            return (-2);
        }

        cv::Mat frame_in;
        while (1)
        {
            if (!cap.read(frame_in)) {
                std::cout << "Capture read error" << std::endl;
                break;
            }
            else {
                writer.write(frame_in);
            }
            cv::imshow("webCamera", frame_in);
            char c = (char)cv::waitKey(10);
            if (c == 27 || c == 'q' || c == 'Q')//ESC
                break;

        }
        cap.release();
        writer.release();
        return 0;
    }
intmain()
{
const char*gst=“rtspsrc location=rtsp://latency=0!rtph264depay!avdec_h264!videoconvert!appsink”;
const char*gst\u writer=“appsrc!autovideoconvert!x264enc!mp4mux!filesink location=test.mp4”;
cv::视频捕获上限(gst);
如果(!cap.isOpened()){

std::cout发生了什么错误?您知道
mp4mux
faststart
选项吗?对不起,我以为Gstreamer文件引起了麻烦。。