A command line utility and library for converting DOCX and TXT files to Avid Script Files (.avc)
Project description
pyavc
pyavc is a Python library that allows you to convert DOCX or TXT files into Avid Script (.avc) files. It can be used both as a command-line tool and as a library within your Python scripts.
This project is not affiliated with Avid or Avid Media Composer; it is simply an open-source helper library to make fellow AEs' lives a bit easier.
Installation
To install pyavc, you can use pip3:
pip3 install pyavc
Import Syntax
Use the following syntax to import the functionality into your Python script:
from avc.core import convert
Usage
As a Python Library
The main (and only) method provided is convert. It allows you to convert a DOCX or TXT file and save the result to a specified output directory, with extensive formatting options.
convert(filepath,
output_dir,
output_name=None,
text_width=80,
font_size=12,
font_name="Open Sans",
white_bg=False,
show_row_colors=True,
left_margin=40,
text_width_px=512,
show_frames=True,
interpolate_position=False,
show_all_takes=True,
show_line_numbers=True,
word_wrap=True,
hold_slates_onscreen=False,
take_color=1
)
HINT: Only the input file and output folder path are mandatory. The default values are configured to match Avid's default settings. Keyword arguments are highly recommended (though not enforced), as they allow you to pick and choose which parameters you actually want to alter.
Parameters
filepath(str): The path to the input DOCX or TXT file. If using a TXT file, it must be encoded as UTF-8.output_dir(str): The path to the output directory where the converted file will be saved.output_name(str, optional): The name of the output file (without extension). If not provided, the name is based on the input file.pyavcwill not overwrite existing files but will append a number to the filename. Defaults toNone.text_width(int, optional): The maximum number of characters before a line break is inserted. This avoids paragraphs being treated as a single line in Avid. Defaults to80.font_size(int, optional): The display font size in pixels. Maximum size is 255. Defaults to12.font_name(str, optional): The name of the font to use (e.g., "Arial", "Courier New"). If an invalid font is supplied, Avid will use a system default. Defaults to"Open Sans".white_bg(bool, optional): IfTrue, the script background will be white. IfFalse, it defers to Avid's user settings. Defaults toFalse.show_row_colors(bool, optional): IfTrue, rows will have alternating background colors for readability. Defaults toTrue.left_margin(int, optional): The left margin size in pixels. Defaults to40.text_width_px(int, optional): The width of the text area in pixels. This is for display purposes and does not insert line breaks. Minimum is 128, maximum is 5120. Defaults to512.show_frames(bool, optional): IfTrue, a small thumbnail is displayed on the slate. Defaults toTrue.interpolate_position(bool, optional): IfTrue, allows you to add your own manual sync marks in Avid. Defaults toFalse.show_all_takes(bool, optional): IfTrue, all takes are displayed. IfFalse, only the primary take is shown. Defaults toTrue.show_line_numbers(bool, optional): IfTrue, line numbers are displayed. Defaults toTrue.word_wrap(bool, optional): IfTrue, long lines of text will wrap visually to fit within the margins. Defaults toTrue.hold_slates_onscreen(bool, optional): IfTrue, slate information remains visible in the record monitor until the next slate appears. Defaults toFalse.take_color(int, optional): An integer from 1-22 to select a highlight color for takes. See the color mapping table below for details. Defaults to1.
How the options map to Media Composer's native settings dialog:
Example Usage
from avc.core import convert
# Convert a TXT file with default settings, using positional arguments
convert('/path/to/input.txt', '/path/to/output/dir')
# Convert a DOCX file with a custom output name and font, using keyword arguments
convert(filepath='/path/to/input.docx', output_dir='/path/to/output/dir', output_name='custom_name', font_name='Arial')
Command-Line Usage
pyavc can also be used from the command line to quickly convert files.
Syntax
pyavc -i <path> -o <path> [options]
Parameters
-i, --input: (Required) Path to the input DOCX or TXT file.-o, --output_dir: (Required) Path to the output directory.-n, --output_name: (str, optional) Name of the output file (without extension). If not provided, it will be set by the file name of the input file.-t, --text_width: (int, optional) Max characters before inserting a line break.-f, --font_size: (int, optional) Desired display font size in pixels.-fn, --font_name: (str, optional) Name of the font to use.-wbg, --white_bg: (bool, optional) Use a white background.-r, --show_row_colors: (bool, optional) Show alternating row colors.-ml, --margin_left: (int, optional) Left margin size in pixels.-tpx, --text_width_px: (int, optional) The width of the text area in pixels for display.-sf, --show_frames: (bool, optional) Display mini thumbnail on the slate.-ip, --interpolate_position: (bool, optional) Allow manual sync marks.-a, --show_all_takes: (bool, optional) Show all takes instead of only the primary.-ln, --show_line_numbers: (bool, optional) Show line numbers.-ww, --word_wrap: (bool, optional) Wrap long lines visually.-hs, --hold_slates_onscreen: (bool, optional) Hold slates on screen in the record monitor.-tk, --take_color: (int, optional) An integer (1-22) to specify the take highlight color.
take_color Palette
| take_color | Color | Hex Code |
|---|---|---|
| 1 | #BEBEBE |
|
| 2 | #C04BA0 |
|
| 3 | #C73939 |
|
| 4 | #C17E52 |
|
| 5 | #C0C356 |
|
| 6 | #65C453 |
|
| 7 | #5A97E2 |
|
| 8 | #5846E4 |
|
| 9 | #FF0000 |
|
| 10 | #80FFB8 |
|
| 11 | #007FFF |
|
| 12 | #595959 |
|
| 13 | #7E3169 |
|
| 14 | #802424 |
|
| 15 | #7E5235 |
|
| 16 | #7E8038 |
|
| 17 | #428036 |
|
| 18 | #3B6393 |
|
| 19 | #392E94 |
|
| 20 | #80F1FF |
|
| 21 | #B880FF |
|
| 22 | #F1FF80 |
Example Commands
# Convert a TXT file and save the output
pyavc -i /path/to/input.txt -o /path/to/output/dir
# Convert a DOCX file and specify a custom output name
pyavc -i /path/to/input.docx -o /path/to/output/dir -n custom\_name
# Convert a DOCX file with a custom name, text width, font size, and take color
pyavc -i /path/to/input.docx -o /path/to/output/dir -n MyCustomName -t 50 -f 35 -tk 7
License
This project is licensed under the GPL 3.0 License. See the LICENSE file for more details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request with any improvements or suggestions. I am but a humble assistant editor and programming is more a hobby than a profession, so I'm always open to feedback.
Some Notes
This library is still in the 'finishing touches' phase, and as always, there may be undiscovered bugs.
Acknowledgments
pyavc would not be possible without the pyavb library by markreidvfx, which provided so many useful hints. As it turns out, AVC files are constructed much like AVB files. Who would have thought?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyavc-1.0.21.tar.gz.
File metadata
- Download URL: pyavc-1.0.21.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dd91c0086c915acdafe1f81a9f4c4db79c0b27f007fbc4b62532938b8ac48a7
|
|
| MD5 |
b749b1491e053179e3a8a64eeac8179f
|
|
| BLAKE2b-256 |
582606d2f6cbf507d40eb00dc63e3bf0777fd94845efc49cdb76eb915b0fa2c1
|
File details
Details for the file pyavc-1.0.21-py3-none-any.whl.
File metadata
- Download URL: pyavc-1.0.21-py3-none-any.whl
- Upload date:
- Size: 27.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2feda0384afa770f49d5bcc35c3a56242ef3a4d6e087bae01411c1b2f6b40de
|
|
| MD5 |
005ae400a77df71a9088894a61e93499
|
|
| BLAKE2b-256 |
063694b94033382ccbc2a723c0d56aa19fda39949ea2eb9bf3dcfe4b4ec8696b
|