playing mpegs

BlitzMax Forums/BlitzMax Programming/playing mpegs

Chris C(Posted 2006) [#1]
Got really frustrated trying to decode a midi file (honest its not as easy as you think!) so did this instead...

BlitzMax wrapper of a mpeg decoding lib

*** NB you must demultiplex the video from the audio! ***

TMPGEnc will do this for you, the easiest option is to use the demux tool in the tools menu you will end up with a file with the same compression and dimensions

Example shows an mpeg rotating and zooming


get it from....


Scott Shaver(Posted 2006) [#2]
That's cool, does it work only on windows?


Chris C(Posted 2006) [#3]
in *theory* if you can get the mpeg2 lib to compile on mac it should work okay...... but that might be stretching the word theory to its limits!


xlsior(Posted 2006) [#4]
Sounds great, but it doesn't work for me -- I get an error, "Build Error: failed to compile D:/mikmodmax/mpeg/frame_wrap.cpp"

Does it require MinGW to be installed or something?

Anyway, that "mikmakmod" module player you have is very nice as well. Coincidentally, the mikmak.dll can be reduced to less half of its original size using UPX with a --force flag


popcade(Posted 2006) [#5]
It's suggested to install MinGW and configure it properly to run these codes, however my "Build Modules" button is still inactive.

But the Ctrl+D key works for me.


xlsior(Posted 2006) [#6]
OK, installed MinGW, and works like a charm now. Very impressive!


Chris C(Posted 2006) [#7]
coo a non dead horse type thing - or do I speak too soon!

any mac owners out there fancy taking a bash at getting the meg2 library working?


DannyD(Posted 2006) [#8]
It doesn't appear the permissions were saved when archiving.I did the following on a 10.4.5 Mac Os X box:
./configure
-bash: ./configure: Permission denied

Therefore did a
chmod oug+x configure


Then a configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... powerpc-apple-darwin8.5.0
checking host system type... powerpc-apple-darwin8.5.0
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking whether gcc needs -traditional... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking sys/timeb.h usability... yes
checking sys/timeb.h presence... yes
checking for sys/timeb.h... yes
checking io.h usability... no
checking io.h presence... no
checking for io.h... no
checking altivec.h usability... no
checking altivec.h presence... no
checking for altivec.h... no
checking if gcc supports  -Wall -g -O2 flags... yes
checking if gcc supports  -Wall -g  -O3 flags... yes
checking if gcc supports  -Wall -g  -O3 -fomit-frame-pointer  flags... yes
checking if gcc supports  -Wall -g  -O3 -fomit-frame-pointer -fno-common  flags... yes
checking for altivec.h... (cached) no
checking if gcc supports  -Wall -g  -O3 -fomit-frame-pointer -fno-common  -faltivec  flags... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... no
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -p
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for g77... no
checking for f77... no
checking for xlf... no
checking for frt... no
checking for pgf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for f90... no
checking for xlf90... no
checking for pgf90... no
checking for epcf90... no
checking for f95... no
checking for fort... no
checking for xlf95... no
checking for ifc... no
checking for efc... no
checking for pgf95... no
checking for lf95... no
checking for gfortran... no
checking whether we are using the GNU Fortran 77 compiler... no
checking whether  accepts -g... no
checking the maximum length of command line arguments... 65536
checking command to parse /usr/bin/nm -p output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if gcc static flag  works... yes
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fno-common
checking if gcc PIC flag -fno-common works... yes
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin8.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... no
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fno-common
checking if g++ PIC flag -fno-common works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin8.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
appending configuration tag "F77" to libtool
checking whether time.h and sys/time.h may both be included... yes
checking for struct timeval... yes
checking for inttypes.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for always_inline... yes
checking for restrict... __restrict__
checking for __builtin_expect... yes
checking whether byte ordering is bigendian... yes
checking for working volatile... yes
checking for size_t... yes
checking return type of signal handlers... void
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for _LARGE_FILES value needed for large files... no
checking for gettimeofday... yes
checking for ftime... yes
checking if libtool supports -prefer-non-pic flag... yes
checking for X... libraries /usr/X11R6/lib, headers 
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for XShmCreateImage in -lXext... yes
checking for XvShmCreateImage in -lXv... yes
checking ddraw.h usability... no
checking ddraw.h presence... no
checking for ddraw.h... no
checking for sdl-config... no
checking __attribute__ ((aligned ())) support... 64
configure: creating ./config.status
config.status: creating Makefile
config.status: creating autotools/Makefile
config.status: creating include/Makefile
config.status: creating test/Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating libmpeg2/Makefile
config.status: creating libmpeg2/convert/Makefile
config.status: creating libvo/Makefile
config.status: creating vc++/Makefile
config.status: creating libmpeg2/libmpeg2.pc
config.status: creating libmpeg2/convert/libmpeg2convert.pc
config.status: creating include/config.h
config.status: executing depfiles commands


Then an error on the make
Making all in autotools
make[1]: Nothing to be done for `all'.
Making all in include
make  all-am
Making all in libmpeg2
Making all in convert
make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all-am'.
Making all in libvo
if gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include -I../include   -Wall -g  -O3 -fomit-frame-pointer -fno-common   -MT video_out.o -MD -MP -MF ".deps/video_out.Tpo" \
  -c -o video_out.o `test -f 'video_out.c' || echo './'`video_out.c; \
then mv -f ".deps/video_out.Tpo" ".deps/video_out.Po"; \
else rm -f ".deps/video_out.Tpo"; exit 1; \
fi
if gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include -I../include   -Wall -g  -O3 -fomit-frame-pointer -fno-common   -MT video_out_x11.o -MD -MP -MF ".deps/video_out_x11.Tpo" \
  -c -o video_out_x11.o `test -f 'video_out_x11.c' || echo './'`video_out_x11.c; \
then mv -f ".deps/video_out_x11.Tpo" ".deps/video_out_x11.Po"; \
else rm -f ".deps/video_out_x11.Tpo"; exit 1; \
fi
if gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include -I../include   -Wall -g  -O3 -fomit-frame-pointer -fno-common   -MT video_out_dx.o -MD -MP -MF ".deps/video_out_dx.Tpo" \
  -c -o video_out_dx.o `test -f 'video_out_dx.c' || echo './'`video_out_dx.c; \
then mv -f ".deps/video_out_dx.Tpo" ".deps/video_out_dx.Po"; \
else rm -f ".deps/video_out_dx.Tpo"; exit 1; \
fi
if gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include -I../include   -Wall -g  -O3 -fomit-frame-pointer -fno-common   -MT video_out_sdl.o -MD -MP -MF ".deps/video_out_sdl.Tpo" \
  -c -o video_out_sdl.o `test -f 'video_out_sdl.c' || echo './'`video_out_sdl.c; \
then mv -f ".deps/video_out_sdl.Tpo" ".deps/video_out_sdl.Po"; \
else rm -f ".deps/video_out_sdl.Tpo"; exit 1; \
fi
if gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include -I../include   -Wall -g  -O3 -fomit-frame-pointer -fno-common   -MT video_out_null.o -MD -MP -MF ".deps/video_out_null.Tpo" \
  -c -o video_out_null.o `test -f 'video_out_null.c' || echo './'`video_out_null.c; \
then mv -f ".deps/video_out_null.Tpo" ".deps/video_out_null.Po"; \
else rm -f ".deps/video_out_null.Tpo"; exit 1; \
fi
if gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include -I../include   -Wall -g  -O3 -fomit-frame-pointer -fno-common   -MT video_out_pgm.o -MD -MP -MF ".deps/video_out_pgm.Tpo" \
  -c -o video_out_pgm.o `test -f 'video_out_pgm.c' || echo './'`video_out_pgm.c; \
then mv -f ".deps/video_out_pgm.Tpo" ".deps/video_out_pgm.Po"; \
else rm -f ".deps/video_out_pgm.Tpo"; exit 1; \
fi
rm -f libvo.a
ar cru libvo.a video_out.o video_out_x11.o video_out_dx.o video_out_sdl.o video_out_null.o video_out_pgm.o 
ranlib libvo.a
Making all in doc
if gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include -I../include   -Wall -g  -O3 -fomit-frame-pointer -fno-common  -MT sample1.o -MD -MP -MF ".deps/sample1.Tpo" \
  -c -o sample1.o `test -f 'sample1.c' || echo './'`sample1.c; \
then mv -f ".deps/sample1.Tpo" ".deps/sample1.Po"; \
else rm -f ".deps/sample1.Tpo"; exit 1; \
fi
/bin/sh ../libtool --mode=link gcc -Wall -g  -O3 -fomit-frame-pointer -fno-common    -o sample1  sample1.o ../libmpeg2/libmpeg2.la 
gcc -Wall -g -O3 -fomit-frame-pointer -fno-common -o sample1 sample1.o  ../libmpeg2/.libs/libmpeg2.a
/usr/bin/ld: archive: ../libmpeg2/.libs/libmpeg2.a has no table of contents, add one with ranlib(1) (can't load from it)
collect2: ld returned 1 exit status
make[1]: *** [sample1] Error 1
make: *** [all-recursive] Error 1


Fink doesn't know what MiniGW is so I'll have to google that
fink install minigw
Information about 1747 packages read in 5 seconds.
Failed: no package found for specification 'minigw'!


Googled MiniGW but it appears to be Windows based " collection of freely available and freely distributable Windows specific header files and import libraries combined with GNU toolsets that allow one to produce native Windows programs that do not rely on any 3rd-party C runtime DLLs."

Perhaps there exists a port of mpeg2dec-0.4.0 for Macos, I'll google...


DannyD(Posted 2006) [#9]
Ok got an unstable version of mpeg2dec for Fink, I hope this will dop
mpeg2dec
MPEG-2 video stream decoder
Installed: None
Unstable: 0.4.0b-3
Stable: None
Binary: None
mpeg2dec decodes mpeg-1 and mpeg-2 video streams and also includes a demultiplexer for mpeg-1 and mpeg-2 program streams.
Web site: http://libmpeg2.sourceforge.net
Maintainer: None <fink-devel@...;

fink needs help picking an alternative to satisfy a virtual dependency. The
candidates:

(1)	 xfree86: Free X11 implementation for Darwin and Mac OS X
(2)	 xorg: Free X11 implementation for Darwin and Mac OS X

Pick one: [1] 
The following package will be installed or updated:
 mpeg2dec
The following 5 additional packages will be installed:
 mpeg2dec-shlibs sdl sdl-shlibs xfree



Chris C(Posted 2006) [#10]
so are you saying you got it to work?

if not, you need to get the C examples working first, once you have varified they are working I might be able to help, but bare in mind I dont have a mac...


Chris C(Posted 2006) [#11]
/usr/bin/ld: archive: ../libmpeg2/.libs/libmpeg2.a has no table of contents, add one with ranlib(1) (can't load from it)

look like you might allready be close!

see if libmpeg2.a exists, is there a ranlib tool on mac? you might need to alter the makefile to reflect a different command name or usage???

you might be able to do it manually


popcade(Posted 2006) [#12]
Is this possible to decode "theora" or "xvid" encoded files to the frame?

I'm noob to this, however I thinks someone is powerful to do this, even willing to pay if possible.

It'll be a great thing with a stand alone movie format for BlitzMax......


Chris C(Posted 2006) [#13]
from http://libmpeg2.sourceforge.net/
[qoute]libmpeg2 - a free MPEG-2 video stream decoder[/quote]

you can always convert your media...


DannyD(Posted 2006) [#14]
-rw-r--r--    1 danny  danny  436960 Mar  2 10:13 libmpeg2.a

iBook:~/Desktop/test/mpeg/mpeg2dec-0.4.0/libmpeg2/.libs danny$ ranlib -V
Apple Computer, Inc. version cctools-590.18

Libmpeg2.a exists, ranlib also.I'm not sure what to do here.


Chris C(Posted 2006) [#15]
should be just
ranlib libmpeg2.a
then.....

but I have no idea whats stopping make ...


DannyD(Posted 2006) [#16]
Thanks for the help Chris. I'm going to give up for the moment.
It appears that Ranlib is stopping make. I get the same error message when I run ranlib libmpeg2.a as when I run make. libmpeg2.a appears to be precompiled on some other platform other than MacOs X.

iBook:~/Desktop/test/mpeg/mpeg2dec-0.4.0/libmpeg2/.libs danny$ ranlib libmpeg2.a
ranlib: warning for library: libmpeg2.a the table of contents is empty (no object file members in the library define global symbols)



Chris C(Posted 2006) [#17]
yeah like windows....

you did do make clean before attempting to compile on mac didnt you...

if that doesnt help delete libmpeg2.a and try make again

is there anyone else who *actually* has a mac who can help?


Chris C(Posted 2006) [#18]
I was wondering if anyone had got this working on MacOS and if any Mac user would be interested in helping me make a cross platform module

I'm also interested in automatically demux-ing the audio, but I'm not too sure if that would cause licence problems