diff --git a/README b/README index db5044a..e7c43a2 100644 --- a/README +++ b/README @@ -11,7 +11,7 @@ make sure you have the required software installed. On an ubuntu jaunty or karmic system, I required the following packages: -$ sudo apt-get install tk8.5-dev libfreetype6-dev mesa-common-dev python-opengl libglu1-mesa-dev python-pmw python-pygame python-yaml python-dev libglew1.5-dev +$ sudo apt-get install tk8.5-dev libfreetype6-dev mesa-common-dev python-opengl libglu1-mesa-dev python-pmw python-pygame python-yaml python-dev libglew1.5-dev inkscape Then go into the source directory diff --git a/README.movies b/README.movies index e483d8a..9329080 100644 --- a/README.movies +++ b/README.movies @@ -3,14 +3,51 @@ The pygame movie player is used, which is based on SDL/SMPEG. It is no where near as flexible a player as mplayer, for example. It plays MPEG-1 video, and MPEG-2 audio ... and even then it is rather fussy. +Script +******************* + +in ${SLITHY_SRC_DIR}/utils there is a to_pygame_movie.py script +for converting xvidcap + +Notes: +1) xvidcap->settings->XDamage disabled for OpenGL capture + +2) ${SLITHY_SRC_DIR}/utils/to_pygame_movie.py test-0000.mpg +-> generates "pygame_test-0000.mpeg_30fps.avi" + + +Manual +******************* + In short, encode mpegs for this module as the following example: -mencoder something_completely.flv -vf scale=320:240 -of mpeg -mpegopts \ -format=mpeg1:tsaf:muxrate=2000 \ - -o test.mpg -srate 44100 -af lavcresample=44100 -oac twolame \ --twolameopts br=160 \ +mencoder something_completely.flv -vf scale=320:240 -of mpeg -mpegopts format=mpeg1:tsaf:muxrate=2000 \ + -o test.mpg -srate 44100 -af lavcresample=44100 -oac twolame -twolameopts br=160 \ + -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate=1152:keyint=15:mbd=2 + +mencoder rtf_cut.avi -vf scale=400:300 -of mpeg -mpegopts format=mpeg1:tsaf:muxrate=2000 \ + -o rtf_cut_pygame.mpg -srate 44100 -af lavcresample=44100 -oac copy \ -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate=1152:keyint=15:mbd=2 +mencoder -really-quiet -lavdopts threads=4 "dv3d_waxholm_labels.mpeg" -ovc raw -nosound -vf scale,format=i420,harddup -ofps 30 -of rawvideo -o - | x264 --crf 18 --partitions none --me dia --merange 4 --mvrange 64 --subme 0 --no-chroma-me --aq-mode 0 --threads auto --no-cabac --no-deblock --no-psnr --no-ssim --progress --fps 30 --output "dv3d_30fps.avi" - 1380x758 + +mencoder dv3d_30fps.avi -vf scale=640:480 -of mpeg -mpegopts format=mpeg1:tsaf:muxrate=2000 \ + -o dv3d.mpg -srate 44100 -af lavcresample=44100 -oac copy \ + -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate=1152:keyint=15:mbd=2 + + +804x824 + +mencoder -really-quiet -lavdopts threads=4 "waxholm_cortex.mpeg" -ovc raw -nosound -vf scale,format=i420,harddup -ofps 30 -of rawvideo -o - | x264 --crf 18 --partitions none --me dia --merange 4 --mvrange 64 --subme 0 --no-chroma-me --aq-mode 0 --threads auto --no-cabac --no-deblock --fps 30 --output "waxholm_cortex_30fps.avi" - 804x824 + +mencoder waxholm_cortex_30fps.avi -vf scale=640:480 -of mpeg -mpegopts format=mpeg1:tsaf:muxrate=2000 \ + -o pygame_waxholm_cortex_30fps.avi -srate 44100 -af lavcresample=44100 -oac copy \ + -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate=1152:keyint=15:mbd=2 + + + + + For cutting: Mencoder docs: diff --git a/slithy/slidereader.py b/slithy/slidereader.py index d984ed0..f0883ca 100644 --- a/slithy/slidereader.py +++ b/slithy/slidereader.py @@ -180,6 +180,9 @@ def load_slide_content(content): def gen_ppm_name(cache_dir,filename,slide): return os.path.join(cache_dir,filename+'_-%.2d.ppm' % slide) + +def gen_err_ppm_name(cache_dir,filename,slide): + return os.path.join(cache_dir,filename+'_-%.1d.ppm' % slide) def setup_cachedir(path): @@ -227,6 +230,16 @@ def pdf2ppm_cache(filename,slides): final_cmd = cmd % (slide,slide) print final_cmd os.system(final_cmd) + # fix problem with slides <10 coming out with 1 instead of 01 for slide # in filename + if not os.path.exists(target_file): + print "Caught - pdf2ppm bad slide filename numbering" + err_target_file = gen_err_ppm_name(cache_dir,pdf_name,slide) + os.rename(err_target_file, target_file) + + if not os.path.exists(target_file): + raise RuntimeError, "problem getting expected slide file on pdf conversion" + + img = diaimage.get_image(target_file) print 'target_file: ', img diff --git a/utils/to_pygame_movie.py b/utils/to_pygame_movie.py new file mode 100755 index 0000000..704365c --- /dev/null +++ b/utils/to_pygame_movie.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +# to_pygame_movie.sh movie_name + +#sudo apt-get install python-kaa-metadata + +import kaa.metadata +import os +import sys + + +try: + filename = sys.argv[1] +except IndexError: + print "usage: to_pygame_movie.py infile" + sys.exit(1) + +info = kaa.metadata.parse(filename) + +d = {'f':filename} +d['w'] = info.header['hdrl']['avih']['dwWidth'] +d['h'] = info.header['hdrl']['avih']['dwHeight'] +d['out_w'] = 640 +d['out_h'] = 480 + +# convert to 30fps +s = "mencoder -really-quiet -lavdopts threads=4 %(f)s -ovc raw -nosound -vf scale,format=i420,harddup -ofps 30 -of rawvideo -o - | x264 --crf 18 --partitions none --me dia --merange 4 --mvrange 64 --subme 0 --no-chroma-me --aq-mode 0 --threads auto --no-cabac --no-deblock --fps 30 --output %(f)s_30fps.avi - %(w)dx%(h)d" % d + +err = os.system(s) + +if err!=0: + print "Step 0 failed. aborting." + +# encode for pygame + +s = "mencoder %(f)s_30fps.avi -vf scale=%(out_w)d:%(out_h)d -of mpeg -mpegopts format=mpeg1:tsaf:muxrate=2000 -o pygame_%(f)s_30fps.avi -srate 44100 -af lavcresample=44100 -oac copy -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate=1152:keyint=15:mbd=2" % d + +err = os.system(s) + +if err!=0: + print "Step 0 failed. aborting." +else: + print "Success -> pygame_%s_30fps.avi" % (filename) +