Git Product home page Git Product logo

vcsi's People

Contributors

amietn avatar daugustin avatar dependabot[bot] avatar iusmac avatar jm-duke avatar juippis avatar kai-modrzok avatar kaischu avatar kjerk avatar lingman avatar lsnch avatar mgxhub avatar mvineetmenon avatar raefu avatar retsamff avatar shssoichiro avatar tgseed avatar tiefkuehlpizze avatar vesatoivonen avatar zacker150 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vcsi's Issues

ignore errors when processing multiple files

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.

Ability to skip if contact sheet exists

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? :-)

Enhancement: implement --interval

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.

metadata text formatting

add support for basic formatting, for instance bold, underline or different colors within the text

load arguments from configuration file

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:

  1. CLI arguments
  2. User configuration file
  3. Builtin defaults

Grid parameter incompatible with Interval

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.

  1. --interval 10s -g 5x1
    Creates 5x1 grid instead of sufficiently big grid.
  2. --interval 10s -g 5x0
    vcsi.py: error: argument -g/--grid: Grid must be of the form mxn, where m is the
    number of columns and n is the number of rows.
  3. --interval 10s -g 5x200
    Creates an image of huge height, most of which is black.

crash when ffprobe doesn't pass aspect ratio

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.

Window XP But that does not work

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.

Too many files open error

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.

ImportError: No module named vcsi

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:

  • vcsi.egg-info
  • vcsi
  • dist
  • build
    • bdist.macosx-10.12-x86_64 (THIS FOLDER IS EMPTY)
    • lib
      • vcsi

Refactoring

Code needs refactoring most likely before implementing new features

Wrong colors / YUV > RGB conversion

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

Can't create contact sheet

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

Fails on non-standard aspect-ratios

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

Crashes with python-pillow>4.1.1-1

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.

use sane defaults

make the default font larger, and use prettier default color scheme

timestamp border mode

add an option to display timestamp text with a border around the text instead of a rectangle underneath

Nothing happening

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

Vertical video stretched horizontally

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):
vertical_test mp4

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°

Metadata header templates

Make the metadata header text configurable.

Expose more values than filename, dimensions, file size and duration, for example:

  • video codec, audio codec, bitrate, scan type, frame rate, file size in bytes, etc.

python 2.x support

it's pretty much just a single print statement that makes it not work on 2.x

VCSI crash

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.

Font Issue on Centos 7, Python 3.5

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...

Recursive CS creation

I'm trying to create CS for my movie library.

There are two issues I've found with recursive CS creation:

  1. 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...

  2. I cannot specify that the CS should be created at the same location the video file is at.

E.g.:

  • Movies
    • Interstellar
      • Interstellar.mp4
      • Interstellar.nfo - causes crash
      • Interstellar.mp4.jpg - This should be the location for the CS file

I 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 \
  .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.