Giter VIP home page Giter VIP logo

importsubtitles's Introduction

Import Subtitles for Blender VSE

Addon for adding subtitle files to blender VSE as Text sequences. Using pysub2 python module.

Supported formats by pysubs2 -

  • SubStation Alpha
    • .ass - tested
    • .ssa - not tested

Time-Based Formats

  • SubRip
    • .str - tested
  • MPL2 Time-based format similar to MicroDVD
    • .mpl2 - not tested
  • TMP
    • .tmp - not tested
  • WebVTT
    • .vtt - tested.

Frame-based Formats

  • MicroDVD -.sub - not tested

UI

Input Section: UI

  • String input - takest the full file path to your subtitle file.
  • Sub Import button - runs the script that imports subtitles as sequences of type 'Text'.
    • sequences are placed on the two topmost channels in VSE.
    • only two line subtitles are supported
    • pressing the button again will compare the sequences and their text,start time, end time, and will apply the changes.

NOTE: Updating sequences(in cases where the sequence/text is on the first channel or the one/lower line subtitle) because blender does not allow two sequences to overlap in one channel and because I didn't spent time to make it account for that, changing the time might result in that line popping to the above channel.

Update section UI2

  • Takes the position, font size, and box margin settings and exposes them to the user.
    • Note: these are the selected sequence's settings you don't need to edit those there but I just exposed them in the panel.
  • Sub Update buttom - runs the update script. Updates position based on the single line seqnece's position, font size and box margin(mainly because the double line subtitles's position have to be updated as well)

All other changes like font color,box margin or box margin color can be applied via the Copy to Selected so I haven't implemented anything to deal with this.

importsubtitles's People

Contributors

okuma10 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

importsubtitles's Issues

Using pip to install modules

If you want to add pip installing of external modules, it can be done like this:

import bpy, sys, subprocess, site

app_path = site.USER_SITE
if app_path not in sys.path:
    sys.path.append(app_path)

pybin = sys.executable  # bpy.app.binary_path_python # Use for 2.83

try:
    subprocess.call([pybin, "-m", "ensurepip"])
except ImportError:
    pass

try:
    import pysubs2
except ImportError:
    subprocess.check_call([pybin, "-m", "pip", "install", "pysubs2"])
    import pysubs2```

A few notes and ideas

Nice to see you working on this.

A few notes:
If you want to add an open-filebrowser button next to the path, there is a template for this in the Template menu: operator_file_import.py

After the import I get this error:
AttributeError: 'Context' object has no attribute 'active_sequence_strip' - I'm running the add-on in 2.93. But it works in 3.0: https://developer.blender.org/rBSc84d1ad3dbf4551b55f7b2630ef4ba7f6512b775https://developer.blender.org/rBSc84d1ad3dbf4551b55f7b2630ef4ba7f6512b775

For some odd reason can't the font type be batch changed with Copy to Selected, so maybe you can find a way to work around that?

The text strips can actually insert text with forced text breaks, but you just can't insert them manually in the string widget. Adding a string like this "line 1"+chr(13)+"line 2" to the text strip will draw the text in two lines.

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.