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.
To install pyavc
, you can use pip3
:
pip3 install pyavc
Use the following syntax to import the functionality into your Python script:
from avc.core import convert
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.
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.pyavc
will 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
.
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')
pyavc
can also be used from the command line to quickly convert files.
pyavc -i <path> -o <path> [options]
-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.
# 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
This project is licensed under the GPL 3.0 License. See the LICENSE
file for more details.
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.
This library is still in the 'finishing touches' phase, and as always, there may be undiscovered bugs.
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?