View Single Post
Old 01-13-2014, 02:56 AM   #1
ppoo
Connoisseur
ppoo writes the songs that make the whole world sing.ppoo writes the songs that make the whole world sing.ppoo writes the songs that make the whole world sing.ppoo writes the songs that make the whole world sing.ppoo writes the songs that make the whole world sing.ppoo writes the songs that make the whole world sing.ppoo writes the songs that make the whole world sing.ppoo writes the songs that make the whole world sing.ppoo writes the songs that make the whole world sing.ppoo writes the songs that make the whole world sing.ppoo writes the songs that make the whole world sing.
 
Posts: 56
Karma: 40393
Join Date: May 2012
Device: Kindle Touch
Smile Convert video lecture + subtitle to images

As title, convert video lecture to which has subtitle belongs to images. These images include 1 image with subtitle at start time of subtitle, and 1 image without image at end time of subtitle.
I think it is not only useful to have video lecture note(note imbeded in image) rather than just note, but also it can be read on Kindle as series' images.

Python command to convert video to image ( especially video lectures)
Usage:
Code:
python vidlec2img.py --video-file-path ~/home/test.mp4
By default subtitle should be in same folder as video file with extension .srt.
For more detail running with --help flag
Requirement:
  • Python 2.7.6
  • Numpy MKL-1.8.0
  • OpenCV 2.4.7 or 2.4.8
  • Pysrt
  • Pillow-2.3.0
  • Requests
Can download all these libraries from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/

Attachments contains images with input is video lecture: 1 - 2 - Tools Setup for Linux (12_24) - Functional Programming course on Coursera.org

And git repo: https://github.com/anhhh11/vidlec2img

Note: It also works quite well with video from Internet (at least http as I've tried) but first you must have its subtitle file .srt and then set --output-path pararameter. It can also be use to preview some videos like youtube thumbnails but bigger and has subtitle and at most faster because it only seek particular images Thanks for opencv.

UPDATE:
  • Unicode support, and more options for changing (subtitle size/color/margin/border)
  • Add resume feature.
  • Change others file path to depend on subtitle file.
  • Allow streaming from http link with redirect; With video required login using --cookie-json-path to add cookie ( only accept cookie export by Google Chrome extension named "Edit This Cookie".
  • Fix unicode subtitle reading error.
  • Add scale image function
  • Add archiving function
  • Add converting from list function
  • Running and result:
  • Fix error pick same images for many subtitle
  • - I've just tested 30min, first time run on my KT and check the video. Sorry for ones've downloaded before ;( . It works well now
Code:
$ python vidlec2img.py -vp "C:/video/Programming/FunctionalProgramming/1 - 2 -
Tools Setup for Linux (12_24).mp4" --font-path C:/arial.ttf -iot JPG -ST -ff  F
ONT_HERSHEY_COMPLEX_SMALL
[##############################] - 100.0% - 143/143 Total
Done!
Elapsed time: 0:00:18.534677
converting from list:
Code:
#list structure
[ ["http://subtitle1.srt", "http://sub", "foldername1" ],
 ["http://subtitle1.srt", "http://sub", "foldername1" ]
]
command convert from folder: (I've use -t flag for testing first 10 image so when using resume mode (-R) it skips these images.

Code:
$>python ~/Desktop/video_lecture_to_img/vidlec2img.py -fsp "/mnt/sda5/video/DataA/IntroMSBigData/" -G -bsz 2 -fp "/usr/share/fonts/truetype/droid/DroidSerif-Regular.ttf" -ST -RSZ -U -R -MM
MSBigDataM01_mid
[##############################] - 98.56% - 685/695 Total
Skip 10 subtitle row
Done!

MSBigDataM02_mid
[##############################] - 98.25% - 562/572 Total
Skip 10 subtitle row
Done!

MSBigDataM03_mid
[##############################] - 98.98% - 970/980 Total
Skip 10 subtitle row
Done!

MSBigDataM04_mid
[##############################] - 97.68% - 421/431 Total
Skip 10 subtitle row
Done!

MSBigDataM05_mid
[##############################] - 98.93% - 922/932 Total
Skip 10 subtitle row
Done!

Elapsed time: 0:07:46.100000
Attached Thumbnails
Click image for larger version

Name:	image-00006.jpg
Views:	442
Size:	28.4 KB
ID:	118471   Click image for larger version

Name:	image-00007.jpg
Views:	420
Size:	25.0 KB
ID:	118472   Click image for larger version

Name:	image-00008.jpg
Views:	405
Size:	25.9 KB
ID:	118473   Click image for larger version

Name:	image-00009.jpg
Views:	408
Size:	27.3 KB
ID:	118474   Click image for larger version

Name:	image-00010.jpg
Views:	395
Size:	19.6 KB
ID:	118475  
Attached Files
File Type: zip video_lecture_to_img.zip (11.1 KB, 318 views)

Last edited by ppoo; 01-29-2014 at 08:26 AM. Reason: fix bug, add new image
ppoo is offline   Reply With Quote