STB style MPEG video writer
Announcing my STB style 256 lines of code MPEG1/2 writer!
In this initial release the features are:
1) 256 lines of C code (single file)
2) no memory allocations
3) public domain
4) patent free (as far as I know)
There is a lot left to be done, notably the encoding of P frames and audio. However, this is very useful as is for a drop-in MPEG writer in any project.
FILE *fp = fopen("foo.mpg", "wb");
jo_write_mpeg(fp, frame0_rgbx, width, height, 60);
jo_write_mpeg(fp, frame1_rgbx, width, height, 60);
jo_write_mpeg(fp, frame2_rgbx, width, height, 60);
Some notes that this writer takes advantage of the fact that MPEG1/2 is designed so that you can literally concatenate files together to combine movies. Technically each frame is its own movie (until p-frames are implemented, then a set of frames would be its own movie).
Some video players mess up here and don't decode correctly, but MPlayer, SMPlayer, FFMpeg and others work correctly. So this is great as a quick intermediate format!
Have fun and code responsibly! (j/k)
5/8/2017 08:16:50 am
Is there any possibility to improve quality of the video? It is being far more stronger copressed then I need for my purpose. Even lossless format would be great.
8/14/2019 03:59:44 pm
Is there a way to add audio to it?
3/12/2021 01:19:25 am
thank you very much for your work, but I have a question.
Leave a Reply.