elsampsa / valkka-core

Valkka - Create video surveillance, management and analysis programs with PyQt
GNU Lesser General Public License v3.0
181 stars 35 forks source link

Recording in MP4 format #43

Closed apokerce closed 1 year ago

apokerce commented 1 year ago

General Question

Hi Elampsa, I am trying to convert the fileframefilter to support mp4 format. I am not quite familiar with ffmpeg but I so some examples in which people are saying i=avformat_alloc_output_context2(&av_format_context, NULL, “matroska”, NULL); Should be changed from matroska to mp4 and change the codec. However, I did try many things like changing the init part but the produced mp4 file were always broken. Also, I tried to read dumpfile directly to record in mp4 but I could not find how you compressing the frames in filesystem. Can you provide me what I am missing or how to read dumpfile to write my own mp4 recorder. Thanks in advance.

elsampsa commented 1 year ago

From the top of my head, check out

muxer.cpp: FragMP4MuxFrameFilter

That implements writing H264 stream with mp4. If I remember correctly, in mp4 you need to write some metadata "packets" in a specific way before writing the stream itself & I myself struggled quite a bit with that.

If you are seriously doing this, create a development branch, then create new cpp & h files in your branch (filestream2.h/cpp ?), a minimal cpp level test (like in the test/ folder) , see that the test runs at least (and tries to produce a mp4 file) and then give me access to your branch.