Is there any way to write h264 encoded video stream in a matroska file with gstreamer?

356 Views Asked by At

I have to get a processed video from gstreamer pipe, compress it based on h264 or h265 alg. and then write it to storage. There are some problems in this project that must be handled:

  1. Saved video must be playable by any standard video players such as vlcplaye, windows media player, kmplayer and ...
  2. If for any reason the destination file does not close properly (such as a power outage), the entire file should not be lost and the saved video should be playable until the problem occurs. My solution to this project with these constraints, is an opencv writer with a gstreamer pipe as follow:
...
std::string gstPipe("appsrc ! videoconvert ! omxh264enc ! "
                    "splitmuxsink muxer=matroskamux "
                    "max-size-time=50000000000 location="
                    "/file/path/save%d.mkv");     
cv::Size frameSize(frameWidth, frameHeight);
bool result = videoWriter.open(gstPipe, cv::CAP_GSTREAMER, 0,
                         fps, frameSize);

This solution splits a video stream into multiple files, but it is needed to save whole video in one file. Does anyone have a better solution to offer? Thank you very much in advance for your helps.

0

There are 0 best solutions below