filmov
tv
ASCII train, Libcaca video ( img2txt ) + HowTo.

Показать описание
ASCII video, libcaca. Width is 180 columns, resolution 1280x720, 5 fps.
Libcaca video HOWTO:
==============================
- Linux CLI only
- Angled brackets in script are in the html form ">", replace them in source please.
Python converter: HTML to IMAGE.
Imgkit - Python 2 and 3 wrapper for wkhtmltoimage utility to convert HTML to IMG using Webkit.
Imgkit is doing the most important part. It converts an intermediate HTML to a PNG image.
The Imgkit is used instead of the outdated Webkit2png. The Webkit2png doesn't work with new QT.
1) nedded: Imgkit - Python 2 and 3 wrapper for the wkhtmltoimage utility to convert HTML to IMG using Webkit
**********************************
import imgkit
import sys
options = {
'quiet': '',
'quality': '100'
}
**********************************
3) Demo version of bash script (it's slow):
**********************************
#!/bin/bash
f=$( ls *.mp4 )
for i in $(ls | grep jpg | sort) ; do
echo $i
j=$( echo $i | sed '1,$ s/\(.*\)\.jpg/\1/')
done
**********************************
4) Parallel processing bash script, 1 image per CPU core:
**********************************
#!/bin/bash
c=16 # CPU cores
echo
echo "############################## 1 ################################"
echo
f=$( ls *.mp4 ) # .mp4 input
echo
echo "############################## 2 ################################"
echo
for i in $(ls | grep jpg | sort) ; do
j=$( echo $i | sed '1,$ s/\(.*\)\.jpg/\1/')
s=$( ps -ef | grep img2txt | grep -v grep | wc -l )
while [[ $s -ge $c ]] ; do
echo -n "."
sleep 1
s=$( ps -ef | grep img2txt | grep -v grep | wc -l )
if [[ $s -lt $c ]]
then
echo "."
fi
done
done
echo
echo "############################## 3 ################################"
echo
for i in $(ls | grep html | sort) ; do
j=$( echo $i | sed '1,$ s/\(.*\)\.html/\1/')
echo $s
while [[ $s -ge $c ]] ; do
echo -n "."
sleep 1
if [[ $s -lt $c ]]
then
echo "."
fi
done
done
echo
echo "############################## 4 ################################"
echo
for i in $(ls | grep _ | grep png | sort) ; do
j=$( echo $i | sed '1,$ s/_\(.*\)\.png/\1/')
s=$( ps -ef | grep convert | grep -v grep | wc -l )
echo $s
while [[ $s -ge $c ]] ; do
echo -n "."
sleep 1
s=$( ps -ef | grep convert | grep -v grep | wc -l )
if [[ $s -lt $c ]]
then
echo "."
fi
done
done
echo
echo "############################## 5 ################################"
echo
f=$( cat $f | sed '1,$ s/\(.*\)\.mp4/\1/' )
rm *.png
exit 0
**********************************
Libcaca video HOWTO:
==============================
- Linux CLI only
- Angled brackets in script are in the html form ">", replace them in source please.
Python converter: HTML to IMAGE.
Imgkit - Python 2 and 3 wrapper for wkhtmltoimage utility to convert HTML to IMG using Webkit.
Imgkit is doing the most important part. It converts an intermediate HTML to a PNG image.
The Imgkit is used instead of the outdated Webkit2png. The Webkit2png doesn't work with new QT.
1) nedded: Imgkit - Python 2 and 3 wrapper for the wkhtmltoimage utility to convert HTML to IMG using Webkit
**********************************
import imgkit
import sys
options = {
'quiet': '',
'quality': '100'
}
**********************************
3) Demo version of bash script (it's slow):
**********************************
#!/bin/bash
f=$( ls *.mp4 )
for i in $(ls | grep jpg | sort) ; do
echo $i
j=$( echo $i | sed '1,$ s/\(.*\)\.jpg/\1/')
done
**********************************
4) Parallel processing bash script, 1 image per CPU core:
**********************************
#!/bin/bash
c=16 # CPU cores
echo
echo "############################## 1 ################################"
echo
f=$( ls *.mp4 ) # .mp4 input
echo
echo "############################## 2 ################################"
echo
for i in $(ls | grep jpg | sort) ; do
j=$( echo $i | sed '1,$ s/\(.*\)\.jpg/\1/')
s=$( ps -ef | grep img2txt | grep -v grep | wc -l )
while [[ $s -ge $c ]] ; do
echo -n "."
sleep 1
s=$( ps -ef | grep img2txt | grep -v grep | wc -l )
if [[ $s -lt $c ]]
then
echo "."
fi
done
done
echo
echo "############################## 3 ################################"
echo
for i in $(ls | grep html | sort) ; do
j=$( echo $i | sed '1,$ s/\(.*\)\.html/\1/')
echo $s
while [[ $s -ge $c ]] ; do
echo -n "."
sleep 1
if [[ $s -lt $c ]]
then
echo "."
fi
done
done
echo
echo "############################## 4 ################################"
echo
for i in $(ls | grep _ | grep png | sort) ; do
j=$( echo $i | sed '1,$ s/_\(.*\)\.png/\1/')
s=$( ps -ef | grep convert | grep -v grep | wc -l )
echo $s
while [[ $s -ge $c ]] ; do
echo -n "."
sleep 1
s=$( ps -ef | grep convert | grep -v grep | wc -l )
if [[ $s -lt $c ]]
then
echo "."
fi
done
done
echo
echo "############################## 5 ################################"
echo
f=$( cat $f | sed '1,$ s/\(.*\)\.mp4/\1/' )
rm *.png
exit 0
**********************************