Windows x64
Licence MIT
Mpeg1 and MP2 are patent free, all claims have ceased since 2017 when Mp3 expired.
To do:
Change audio to use miniaudio lib for cross platform support.
add in additional functions
The wrapper lets you play video on any surface via functions
MPG_GetSprite(Mpg)
MPG_GetTexture(mpg)
MPG_GetMaterial(mpg)
MPG_Image(mpg)
so you can render to Screen, Material, texture, image or window and canvas via image dynamically.
you should also be able to play multiple videos at once, though not tested
And it's very light weight 78kb
if you want to compile the c file your self, it's as easy asPL_MPEG - MPEG1 Video decoder, MP2 Audio decoder, MPEG-PS demuxer
https://github.com/phoboslab/pl_mpeg
clang -O2 -c pl_mpeg.c
Download ;includes test video
https://atomicwebserver.com/MPG.zip
Draw video to cube example
Code: Select all
XIncludeFile "mpg.pbi"
;compile thradsafe
UseModule MPG
InitEngine3D()
InitSprite()
Global st.d,et.d,lt.d
Global mpg = MPG_LoadFile("bjork-all-is-full-of-love.mpg"); Load MPG file
If MPG
Global w,h
w = MPG_GetWidth(mpg) ;get video width
h = MPG_GetHeight(mpg)
InitSprite()
InitKeyboard()
ExamineDesktops():dx=DesktopWidth(0)*0.8:dy=DesktopHeight(0)*0.8
OpenWindow(0, 0,0, DesktopUnscaledX(dx),DesktopUnscaledY(dy), "mpeg",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, dx, dy, 0, 0, 0)
CreateLight(#PB_Any, RGB(255, 255, 255),-5, 10, 5, #PB_Light_Point)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 2, 1, 3, #PB_Absolute | #PB_Local)
CameraLookAt(0, 0, 0, 0)
CreateCube(0, 1.5)
CreateEntity(0, MeshID(0), #PB_Material_None)
textID = CreateTexture(#PB_Any, w, h)
hdc = StartDrawing(TextureOutput(textid))
If hdc
Box(0,0,w,h)
StopDrawing()
MaterialID = CreateMaterial(#PB_Any,TextureID(textID))
SetEntityMaterial(0,MaterialID(MaterialID))
EndIf
MPG_Play(MPG) ;start the playback
Repeat
While WindowEvent() : Wend
ExamineKeyboard()
mat = MPG_GetMaterial(mpg) ;Get material
If mat
SetEntityMaterial(0,MaterialID(Mat)) ;set material to cube
EndIf
RotateEntity(0, 0, 0.3, 0, #PB_Relative)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
MPG_Free(mpg) ;free mpg
EndIf
ffmpeg -i input.mp4 -c:v mpeg1video -q:v 0 -c:a libtwolame -b:a 224k -format mpeg output.mpg
-q:v sets a fixed video quality with a variable bitrate, where 0 is the highest. You may use -b:v to set a fixed bitrate instead; e.g. -b:v 2000k for 2000 kbit/s. Please refer to the ffmpeg documentation for more details.