How to choose Full Frames (uncompressed) as a codec for VideoWriter

I want to store uncompressed frames from the device as video, but I need to know how to select "Full Frames (Uncompressed)" as the codec for VideoWriter (in emgu aka openCV).

I can select it from the dropdown menu when iam passes -1, like this

VideoWriter myVideoWriter = new VideoWriter ("myVieoColor.avi", -1 , 15, videoSize, true);

But I want to automatically select codecs with a full frame (uncompressed). For example, I know that I can select Lagarith Lossless Video video cards on

VideoWriter myVideoWriter = new VideoWriter ("myVieoColor.avi", Emgu.CV.VideoWriter.Fourcc('L','A','G','S') , 15, videoSize, true);

but I can’t determine which of the four pieces I need to use.

Maybe someone can help me.

+4
source share
3 answers

, , , AVISaveOptions(...). , , , - 799 fourcc.

:

  • foo.avi 1 , .
  • foo.avi cv::VideoCapture.
  • CAP_PROP_FOURCC cv::VideoCapture.
  • .
  • [] bar.avi 1 FOURCC, 3. foo.avi bar.avi, , .

, #/EmguCV, , .

++

#include <opencv2/opencv.hpp>
#include <iostream>

int main()
{
    {
        cv::VideoWriter outputVideo;
        outputVideo.open("foo.avi", -1, 25.0, cv::Size(640, 480), true);

        cv::Mat frame(480, 640, CV_8UC3);
        outputVideo.write(frame);
    }

    cv::VideoCapture inputVideo("foo.avi");
    int fourcc = static_cast<int>(inputVideo.get(CV_CAP_PROP_FOURCC));

    char FOURCC_STR[] = {
        (char)(fourcc & 0XFF)
        , (char)((fourcc & 0XFF00) >> 8)
        , (char)((fourcc & 0XFF0000) >> 16)
        , (char)((fourcc & 0XFF000000) >> 24)
        , 0
    };
    std::cout << "FOURCC is '" << FOURCC_STR << "'\n";

    return 0;
}

:

FOURCC is 'DIB '

Python

import cv2
import numpy as np
import struct

outputVideo = cv2.VideoWriter()
outputVideo.open("foo.avi", -1, 25, (640,480), True)

frame = np.zeros((480,640,3), dtype=np.uint8)
outputVideo.write(frame)
outputVideo.release()

inputVideo = cv2.VideoCapture("foo.avi")
fourcc = int(inputVideo.get(cv2.cv.CV_CAP_PROP_FOURCC))

print "FOURCC is '%s'" % struct.pack("<I", fourcc)

:

FOURCC is 'DIB '
+3

Opencv

:

- > backends fourcc = -1 .

- > , (, img_% 02d.jpg) fourcc = 0 fps = 0. (, img_% 02d.BMP), .

- > . , (, FFMPEG FFV1, Huffman HFYU, Lagarith LAGS ..)

- > FFMPEG, codec = 0; = 0; () .

http://docs.opencv.org/trunk/dd/d9e/classcv_1_1VideoWriter.html#afec93f94dc6c0b3e28f4dd153bc5a7f0

+1

.

, emgu (VideoWriter Capture get (CAP_PROB), CvInvoke.cveVideoCaptureGet.

, , Capture .

//record the Videofile with VideoWriter to "myVideoColor.avi"
capture = new Capture("myVieoColor.avi");
System.Diagnostics.Debug.WriteLine(CvInvoke.cveVideoCaptureGet(capture, Emgu.CV.CvEnum.CapProp.FourCC));

. LAGS , , 1397178700, .

VideoWriter myVideoWriter = new VideoWriter ("myVieoColor.avi", 1397178700 , 15, videoSize, true);
//works great with 1397178700 == LAGS codec

-1 , 0 4CC, 0 808596553

VideoWriter myVideoWriter = new VideoWriter ("myVieoColor.avi", 0 , 15, videoSize, true);
//dont work and CapProb.FourCC returns 808596553

Lagarith Lossless Codec 1397178700, . , ?

PS: Dan Mašek

0

Source: https://habr.com/ru/post/1662031/


All Articles