Skip to content

Commit 7a218f0

Browse files
committed
add type hints to media linker code samples
1 parent 78555ab commit 7a218f0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

docs/tutorials/write-a-media-linker.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ OpenTimelineIO Media Linkers are plugins that allow OTIO to replace MissingRefer
44

55
The current MediaLinker can be specified as an argument to `otio.adapters.read_from_file` or via an environment variable. If one is specified, then it will run after the adapter reads the contents of the file before it is returned back.
66

7+
```python
78
#/usr/bin/env python
89
import opentimelineio as otio
910
mytimeline = otio.adapters.read_from_file("something.edl", media_linker_name="awesome_studios_media_linker")
11+
```
1012

1113
After the EDL adapter reads something.edl, the media linker "awesome_studios_media_linker" will run and link the media in the file (if it can).
1214

@@ -16,25 +18,28 @@ After the EDL adapter reads something.edl, the media linker "awesome_studios_med
1618
To create a new OTIO Adapter, you need to create a file mymedialinker.py. Then add a manifest that points at that python file:
1719

1820

21+
```json
1922
{
2023
"OTIO_SCHEMA" : "PluginManifest.1",
2124
"media_linkers" : [
2225
{
2326
"OTIO_SCHEMA" : "MediaLinker.1",
2427
"name" : "awesome_studios_media_linker",
25-
"execution_scope" : "in process",
2628
"filepath" : "mymedialinker.py"
2729
}
2830
],
2931
"adapters" : [
3032
]
3133
}
34+
```
3235
3336
Then you need to add this manifest to your `$OTIO_PLUGIN_MANIFEST_PATH` environment variable (which is separated with `:` for POSIX or `;` for Windows).
3437

3538
Finally, to specify this linker as the default media linker, set `OTIO_DEFAULT_MEDIA_LINKER` to the name of the media linker:
3639

37-
setenv OTIO_DEFAULT_MEDIA_LINKER "awesome_studios_media_linker"
40+
```bash
41+
export OTIO_DEFAULT_MEDIA_LINKER="awesome_studios_media_linker"
42+
```
3843

3944
To package and share your media linker, follow [these instructions](write-an-adapter.md#packaging-and-sharing-custom-adapters).
4045

@@ -44,17 +49,20 @@ To write a media linker, write a python file with a "link_media_reference" funct
4449

4550
For example:
4651

52+
```python
4753
def link_media_reference(in_clip, media_linker_argument_map):
4854
d.update(media_linker_argument_map)
4955
# you'll probably want to set it to something other than a missing reference
5056
in_clip.media_reference = otio.schema.MissingReference(
5157
name=in_clip.name + "_tweaked",
5258
metadata=d
5359
)
60+
```
5461

5562
## For Testing
5663

5764
The otioconvert.py script has a --media-linker argument you can use to test out your media linker (once its on the path).
5865

66+
```bash
5967
env OTIO_PLUGIN_MANIFEST_PATH=mymanifest.otio.json:$OTIO_PLUGIN_MANIFEST_PATH bin/otioconvert.py -i somefile.edl --media-linker="awesome_studios_media_linker" -o /var/tmp/test.otio
60-
68+
```

0 commit comments

Comments
 (0)