amietn / vcsi Goto Github PK
View Code? Open in Web Editor NEWCreate video contact sheets, thumbnails
License: MIT License
Create video contact sheets, thumbnails
License: MIT License
Running vcsi with either default params (deja vu fonts are installed) or with setting fonts manually results in this error:
Composing contact sheet...
Traceback (most recent call last):
File "/usr/bin/vcsi", line 11, in <module>
load_entry_point('vcsi==6', 'console_scripts', 'vcsi')()
File "/usr/lib/python3.6/site-packages/vcsi/__init__.py", line 3, in main
vcsi.vcsi.main()
File "/usr/lib/python3.6/site-packages/vcsi/vcsi.py", line 1202, in main
process_file(path, args)
File "/usr/lib/python3.6/site-packages/vcsi/vcsi.py", line 1252, in process_file
image = compose_contact_sheet(media_info, selected_frames, args)
File "/usr/lib/python3.6/site-packages/vcsi/vcsi.py", line 733, in compose_contact_sheet
template_path=args.metadata_template_path)
File "/usr/lib/python3.6/site-packages/vcsi/vcsi.py", line 669, in prepare_metadata_text_lines
text=remaining_chars)
File "/usr/lib/python3.6/site-packages/vcsi/vcsi.py", line 633, in max_line_length
text_width = metadata_font.getsize(text_chunk)[0]
File "/usr/lib/python3.6/site-packages/PIL/ImageFont.py", line 156, in getsize
size, offset = self.font.getsize(text, direction, features)
SystemError: <built-in method getsize of Font object at 0x7f986eead990> returned NULL without setting an error
This is true both for when using python-pillow 4.2.1-1 and 4.2.0-1. No such error happens when using python-pillow 4.1.1-1. Using python 3.6.1 on Arch Linux 4.9.37-1-lts.
Hi! Thanks for this wonderful script. I love the metadata template option and I wish you can add a custom message in there too, like Thumbnails generated by amietn.
I was able to install this on CentOS 7 and Python 3.5 but got an error during processing:
Processing video_file.flv...
Composing contact sheet...
Traceback (most recent call last):
File "/usr/bin/vcsi", line 11, in
load_entry_point('vcsi==6', 'console_scripts', 'vcsi')()
File "/usr/lib/python3.5/site-packages/vcsi-6-py3.5.egg/vcsi/init.py", line 3, in main
File "/usr/lib/python3.5/site-packages/vcsi-6-py3.5.egg/vcsi/vcsi.py", line 1255, in main
File "/usr/lib/python3.5/site-packages/vcsi-6-py3.5.egg/vcsi/vcsi.py", line 1305, in process_file
File "/usr/lib/python3.5/site-packages/vcsi-6-py3.5.egg/vcsi/vcsi.py", line 728, in compose_contact_sheet
File "/usr/lib64/python3.5/site-packages/PIL/ImageFont.py", line 238, in truetype
return FreeTypeFont(font, size, index, encoding)
File "/usr/lib64/python3.5/site-packages/PIL/ImageFont.py", line 127, in init
self.font = core.getfont(font, size, index, encoding)
OSError: cannot open resource
You mentioned that it's looking for a DejaVuSans.ttf in /usr/share/fonts/TTF: #30
This folder doesn't seem to exist on a CentOS 7 minimal install as well. Just letting you know that I got everything to work using these steps:
Install Python 3.5:
# yum install https://centos7.iuscommunity.org/ius-release.rpm
# yum install python35u python35u-libs python35u-pip python35u-devel git
Install DejaVuSans font and set /usr/share/fonts/TTF:
# yum install dejavu-sans-fonts
# ln -s /usr/share/fonts/dejavu /usr/share/fonts/TTF
Install vcsi
$ cd /usr/local/src
$ git clone --depth 1 https://github.com/amietn/vcsi.git
$ cd vcsi
$ python3.5 setup.py install
Verify vcsi installation
$ which vcsi
$ /usr/bin/vcsi
$ vcsi --version
$ vcsi version 6
Sample output:
$ vcsi /path/to/video_file.flv -r -t -w 800 -g 4x8 -o /path/to/thumbnails/video_file.jpg
Processing /path/to/video_file.flv...
Composing contact sheet...
Cleaning up temporary files...
50 might be a bit high and the results can be confusing for contact sheets with few selected captures
Make it possible to simply select frames at regular time intervals without using blur detection
The package should be uploaded to the Python Package Index to ease installation.
When running:
vcsi "/Volumes/videos/video.mp4" -t -w 850 -g 3x5 --end-delay-percent 20 -o output.png
I get error:
Traceback (most recent call last): File "/usr/local/bin/vcsi", line 11, in <module> load_entry_point('vcsi==7', 'console_scripts', 'vcsi')() File "build/bdist.macosx-10.12-x86_64/egg/vcsi/__init__.py", line 2, in main ImportError: No module named vcsi
I'm using MacOS 10.12.6. I have installed required modules from a list.
After installation I have those folders:
make it possible to choose the image quality
Instead of generating grid of proper height that fits all generated frames (aka samples), VCSI either throws them away or adds blackness below the grid of actual frames.
E.g.
also make horizontal and vertical margins seperate options
Could you maybe add an os.walk
line where the directory could be given instead of a filename please?
As the title says. Confirmed on multiple videos with this command:
vcsi video.mp4 -t -w 850 -g 3x4 -o output.jpg
This is the error I'm getting:
Traceback (most recent call last):
File "/usr/bin/vcsi", line 11, in <module>
load_entry_point('vcsi==7', 'console_scripts', 'vcsi')()
File "/usr/lib/python3.7/site-packages/vcsi/__init__.py", line 3, in main
vcsi.vcsi.main()
File "/usr/lib/python3.7/site-packages/vcsi/vcsi.py", line 1331, in main
process_file(filename, args)
File "/usr/lib/python3.7/site-packages/vcsi/vcsi.py", line 1343, in process_file
verbose=args.is_verbose)
File "/usr/lib/python3.7/site-packages/vcsi/vcsi.py", line 93, in __init__
self.compute_display_resolution()
File "/usr/lib/python3.7/site-packages/vcsi/vcsi.py", line 157, in compute_display_resolution
sample_aspect_ratio = self.video_stream["sample_aspect_ratio"]
KeyError: 'sample_aspect_ratio'
And a sample file mediainfo
:
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 48 min 5 s
Bit rate : 903 kb/s
Maximum bit rate : 1 940 kb/s
Width : 836 pixels
Height : 626 pixels
Display aspect ratio : 4:3
Frame rate mode : Constant
Frame rate : 13.789 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.125
Stream size : 311 MiB (100%)
Writing library : x264 core 155 r2917 0a84d98
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=13 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=22.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Encoded date : UTC 2018-11-20 17:12:21
Tagged date : UTC 2018-11-20 17:12:21
Codec configuration box : avcC
Finally, vcs
version:
→ vcsi --version
vcsi version 7
We have a large and growing collection of videos we use for production. VCS comes in handy as we can just quickly check if the video we need is the one we think it might be.
As it is a growing collection we have a problem with duplicates JPG file creation. We run a simple vcs *.mp4
command on each folder and that's it. It would be great to have a switch in VCS to check if there is a JPG file already created and skip if there is so. Also, not a bad option would be to force overwrites if necessary.
Sounds like a pretty simple if
case for me, but what do I know? :-)
Instead of just RGB, maybe supporting RGBA as well for the backgound. (Colour behind the image frames)
Allow selection of timestamps via an interval
vcsi.py --interval=5m foo.mkv
would translate to vcsi.py -m 5:00,10:00,15:00 foo.mkv
Requires parsing and then passing a capture_interval
argument to timestamp_generator()
and some conditionals.
make the default font larger, and use prettier default color scheme
When I try to generate thumbnails for a video recorded vertically in a smartphone, the output thumbnails are stretched to 16:9 (instead of the correct 9:16), so they stretch horizontally instead of the correct vertical layout. The content of the thumbnail is displayed correctly though, it's not rotated.
Screenshot of original video, recorded vertically:
Output of vcsi (command vcsi.exe vertical_test.mp4 --quality 70
):
Original video properties, as seen in MPC-HC. Note the field rotation 90°. I imagine vcsi or one of its libraries is not considering this field, because internally the video is 1920x1080, and not the expected 1080x1920.
Video
Format : AVC
Format/Info : Advanced Video Codec
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Width : 1920 pixels
Height : 1080 pixels
Display aspect ratio : 16:9
Rotation : 90°
After an update to FFMPEG 4.0 I get the following error on a few videos in my library when ffprobe doesn't actually list an aspect ratio.
File "/usr/lib/python3.6/site-packages/vcsi/vcsi.py", line 161, in compute_display_resolution sample_aspect_ratio = self.video_stream["sample_aspect_ratio"] KeyError: 'sample_aspect_ratio'
I modified the vcsi.py to try: except: that line and with one that gives a 1:1 ratio when it can't find it.
try: sample_aspect_ratio = self.video_stream["sample_aspect_ratio"] except: sample_aspect_ratio = "1:1"
Uncertain if this is expected behavior from ffmpeg/ffprobe from this point forward, but this fixed the current problem for me.
Currently vcsi will exit as soon as any error occurs. This makes processing a large directory containing some non-video files impossible.
Ignore any error (just display a warning) and skip to the next file when processing multiple files at once.
it's pretty much just a single print statement that makes it not work on 2.x
Make it possible to pass the time format for timestamp labels
Using the latest version on Mac OSX El Capitan
Getting this error:
Composing contact sheet...
Traceback (most recent call last):
File "vcsi.py", line 1134, in <module>
main()
File "vcsi.py", line 1080, in main
process_file(path, args)
File "vcsi.py", line 1125, in process_file
image = compose_contact_sheet(media_info, selected_frames, args)
File "vcsi.py", line 677, in compose_contact_sheet
header_font = ImageFont.truetype(args.metadata_font, args.metadata_font_size)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/PIL/ImageFont.py", line 239, in truetype
return FreeTypeFont(font, size, index, encoding)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/PIL/ImageFont.py", line 128, in __init__
self.font = core.getfont(font, size, index, encoding)
OSError: cannot open resource
This is the command I ran:
vcsi.py file.mp4 -t -w 725 --background-color 000000 --metadata-font-color ffffff -g 4x4 -o ~/Desktop/out.png --end-delay-percent 20
We could read a user-defined vcsi configuration file that would override defaults.
Proposed file location: ~/.config/vcsi/vcsi.conf
The precedence order would be:
Make it possible to specify frames to be used by timestamp
30% is pretty low
remove the flag and put the information in the manpage
Also get rid of the dependency added just for this feature
add an option to display timestamp text with a border around the text instead of a rectangle underneath
Hi,
I want to generate thumbnails previews for a very large number or videos, before sorting them out. I tested VCSI and a few other tools for that purpose, but I noticed that most of them got the colors wrong, including VCSI, MTN, Scorp Video Thumbnails Maker, MPC-HC ; only SMPlayer got the colors right, but it doesn't allow to generate those previews in batch, by treating an entire directory, or to be launched by command line, so I can't practically consider using it for this task. The source files are 1920x1080 AVI / GAVC, and the color conversion matrix should be Bt.709, but apparently ffmpeg uses the Bt.601 by default. I asked for guidance on that matter on VideoHelp forum, ran some tests doing screenshots with ffmpeg and the suggested switches : I obtained the right colors (from a video I edited showing at some point a still picture which I took of a red car, so I could easily see if the colors were right or wrong) with the following switch :
-vf zscale=matrixin=709:matrix=709,format=rgb24
Now the question is : how could I modify the current VCSI script to integrate that switch so as to obtain thumbnail previews with accurate colors ? I don't know anything about the Python language, but looking at the script I can see that there are three instances of ffmpeg calls, apparently which one is actually used depends upon certain parameters of the frame, which I don't quite understand at that point. Will it work if I just add that switch to those three ffmpeg calls and install the modified script with a new name ?
Side question : I also noticed that the thumbnails generated by MPC-HC were slightly sharper than the others (and those generated by MTN definitely blurrier – perhaps it creates JPEG-compressed temporary files, I can't say, it comes as an already compiled .exe and hasn't been updated since 2008 so I doubt that I could reach the author...). Perhaps this could be improved in VCSI by adding a ffmpeg switch to resize with the Lanczos algorithm instead of the default one ?
Another small quibble : the fields available for the file information header are less complete than with MTN : with the video I used for those tests, MTN can display the general average bitrate, the video average bitrate, and the precise type of codec / format used, namely “h264 (High) (GAVC / 0x43564147), yuvj420p (pc, progressive)“, whereas with the current VCSI script no video bitrate field is proposed in the options, and the format is more broadly designated as “H.264 / AVC / MPEG-4 AVC”. VCSI is still better than MPC-HC and SMPlayer in that regard. The Scorp tool is in between in that regard, displaying “GAVC” (which seems more specific than “AVC”) and the video average bitrate, but with the free licence it puts a giant logo on each generated image, and the colors are also wrong, so it's not usable. Right now VCSI looks like the best option.
By the way, what does the “I” stand for in “VCSI” ?
It would be nice to have a quick feedback, at least regarding the main issue (color shifting), so I could get started with this task which is going to be a long hassle in and of itself ! :^p
Thanks in advance.
The relevant threads on VideoHelp :
https://forum.videohelp.com/threads/390691-Generating-video-thumbnails-preview-contact-sheet-in-batch-color-issue
https://forum.videohelp.com/threads/390710-Screenshots-and-respect-of-the-YUV-RGB-colorspace-conversion
add support for basic formatting, for instance bold, underline or different colors within the text
When not specifying a single file, but rather a whole directory, the following exception is raised:
Traceback (most recent call last):
File "/usr/local/bin/vcsi", line 9, in <module>
load_entry_point('vcsi==6', 'console_scripts', 'vcsi')()
File "/usr/local/lib/python3.5/site-packages/vcsi-6-py3.5.egg/vcsi/__init__.py", line 3, in main
File "/usr/local/lib/python3.5/site-packages/vcsi-6-py3.5.egg/vcsi/vcsi.py", line 1297, in main
File "/usr/local/lib/python3.5/site-packages/vcsi-6-py3.5.egg/vcsi/vcsi.py", line 1315, in process_file
File "/usr/local/lib/python3.5/site-packages/vcsi-6-py3.5.egg/vcsi/vcsi.py", line 79, in __init__
File "/usr/local/lib/python3.5/site-packages/vcsi-6-py3.5.egg/vcsi/vcsi.py", line 105, in probe_media
File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 626, in check_output
**kwargs).stdout
File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 693, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1454, in _execute_child
errpipe_read, errpipe_write = os.pipe()
OSError: [Errno 24] Too many open files
I am not sure if this is OS X specific, but it still happens after I raise the max amount of open files and processes allowed. This happens after processing just 5 videos.
I'm trying to create CS for my movie library.
There are two issues I've found with recursive CS creation:
I cannot specify which files to include and which to exclude in the recursion. E.g. if there is a .txt
file somewhere in a folder, vcsi crashes. Edit: I found the --ignore-errors
switch to at least prevent crashing. I guess this is good enough...
I cannot specify that the CS should be created at the same location the video file is at.
E.g.:
Interstellar.mp4
Interstellar.nfo
- causes crashInterstellar.mp4.jpg
- This should be the location for the CS fileI couldn't find any options allowing me to do this.
I'm running this command in ./Movies
:
vcsi \
-w 850 \
-t \
-T nw \
-g 3x6 \
--background-color 000000 \
--metadata-font-color ffffff \
--end-delay-percent 0 \
-r \
.
When I run this:
vcsi Test.avi --show-timestamp --width 1920 --grid "5x4" --end-delay-percent 10 --start-delay-percent "0" --output Test-preview.jpg
I get this error:
Traceback (most recent call last):
File "/usr/bin/vcsi", line 6, in
from pkg_resources import load_entry_point
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 3019, in
@_call_aside
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 3003, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 3032, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 655, in _build_master
ws.require(requires)
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 963, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 849, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'vcsi==6' distribution was not found and is required by the application
I have the following packages installed on an uptodate Arch 64 system as per the vcsi dependencies list:
python-3.6.0-1
ffmpeg-1:3.2.2-2
python-numpy-1.11.3-1
python-pillow-4.0.0-2
python-jinja-2.8.1-1
python-texttable-0.8.7-2
ttf-dejavu-2.37-1
On January 6 I updated python from 3.5.2-3 to 3.6.0-1. Before that I am pretty sure that vcsi worked. I would downgrade python but LibreOffice requires python 3.6.
Thanks for a very usefull utility.
hi amiten.
What is the vcsi Python version?
I compiled with version Window XP, python 3.4.4 .
But that does not work
I will need your help.
Code needs refactoring most likely before implementing new features
Make the metadata header text configurable.
Expose more values than filename, dimensions, file size and duration, for example:
update arch PKGBUILDs and readme
vcsi needs a logo
add some way to align text (for example with tabs)
I have all dependencies installed, but when I run the script, nothing happens.
E.g.:
python3.5 vcsi.py bbb_sunflower_2160p_60fps_normal.mp4 -t -w 850 -g 4x4 --background-color 000000 --metadata-font-color ffffff
python2.7 vcsi.py bbb_sunflower_2160p_60fps_normal.mp4 -t -w 850 -g 4x4 --background-color 000000 --metadata-font-color ffffff
vcsi bbb_sunflower_2160p_60fps_normal.mp4 -t -w 850 -g 4x4 --background-color 000000 --metadata-font-color ffffff
Even with the verbose
switch I get no output at all.
Tested on Centos7 and MacOS Sierra
optional user-defined watermark text used as a background for the header
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.