amietn / vcsi

Create video contact sheets, thumbnails
MIT License
503 stars 57 forks source link

How to use --template to shows metadata info from videos? #95

Closed S-hdyn closed 3 years ago

S-hdyn commented 3 years ago

Hi, how to generate look from https://i.ibb.co/jHXJJyC/Justice-Is-Gray-2021-720p-WEB-DL-x264-Pahe-in.jpg . I didn't understand to use --template options. Usually just use this command vcsi (drag n drop) -t -w 1280 -g 1x1 --background-color 000000 --metadata-font-color ffffff --end-delay-percent 20 --metadata-font C:\Windows\Fonts\Arial.ttf --timestamp-font C:\Windows\Fonts\Arial.ttf So the question is, what's the command to make like this pict https://i.ibb.co/jHXJJyC/Justice-Is-Gray-2021-720p-WEB-DL-x264-Pahe-in.jpg . Also, how to add text like Encoded by: pahe.in I'm very curious but didn't undertand at all. Thanks :)

amietn commented 3 years ago

@S-hdyn To use the --template option. First, write your template to a file, for example template.txt. Then pass that file as argument to the --template option, such as:

vcsi --template template.txt

This is not exactly what you asked for, but something very similar could be achieved with this template:

File: {{filename}}
Size: {{size_bytes}} bytes ({{size}}), duration: {{duration}}, avg bitrate: {{(video_bit_rate or 0 + audio_bit_rate or 0) / 1024}} kb/s
Audio: {{audio_codec}}, {{audio_sample_rate}} Hz
Video: {{video_codec}}, {{display_width}}x{{display_height}}, {{frame_rate}} fps
Encoded by: pahe.in

Currently, vcsi doesn't expose subtitles metadata, nor the overall bit rate. For a reference of what metadata template arguments can be used in templates, see https://github.com/amietn/vcsi#exposed-metadata-template-attributes

S-hdyn commented 3 years ago

I'm sorry. I still got error. The command that I'm trying just vcsi (drag n drop files) --template template.txt but giving no success. This is the error

Traceback (most recent call last):
  File "c:\program files\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python36\Scripts\vcsi.exe\__main__.py", line 9, in <module>
  File "c:\program files\python36\lib\site-packages\vcsi\__init__.py", line 3, in main
    vcsi.vcsi.main()
  File "c:\program files\python36\lib\site-packages\vcsi\vcsi.py", line 1518, in main
    process_file(filename, args)
  File "c:\program files\python36\lib\site-packages\vcsi\vcsi.py", line 1649, in process_file
    image = compose_contact_sheet(media_info, selected_frames, args)
  File "c:\program files\python36\lib\site-packages\vcsi\vcsi.py", line 893, in compose_contact_sheet
    template_path=args.metadata_template_path)
  File "c:\program files\python36\lib\site-packages\vcsi\vcsi.py", line 791, in prepare_metadata_text_lines
    template = Template(template).render(params)
  File "c:\program files\python36\lib\site-packages\jinja2\environment.py", line 1090, in render
    self.environment.handle_exception()
  File "c:\program files\python36\lib\site-packages\jinja2\environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "c:\program files\python36\lib\site-packages\jinja2\_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 2, in top-level template code
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

Any idea?

amietn commented 3 years ago

Looks like some parentheses were missing, try that:

File: {{filename}}
Size: {{size_bytes}} bytes ({{size}}), duration: {{duration}}, avg bitrate: {{((video_bit_rate or 0) + (audio_bit_rate or 0)) / 1024}} kb/s
Audio: {{audio_codec}}, {{audio_sample_rate}} Hz
Video: {{video_codec}}, {{display_width}}x{{display_height}}, {{frame_rate}} fps
Encoded by: pahe.in
S-hdyn commented 3 years ago

Thank you so much. It works, but any idea why avg bitrate: 0.0 kbps?

amietn commented 3 years ago

Apparently vcsi was not able to read the video and audio bit rate for that file.

S-hdyn commented 3 years ago

Okay. Thank you so much for replying my question. 🙏