Permalink
Browse files

Burnin adapter (#167)

* Uses ffmpeg to burn text overlays into the media based on metadata in each clip.
* Added Pillow (PIP) to travis' pip install to support this.
  • Loading branch information...
repsac authored and jminor committed Oct 5, 2017
1 parent c4916c7 commit 9e7eedac95f7260840ce2f7dfbcc26c1a5faf0a7
View
@@ -4,7 +4,7 @@ python:
- "3.5"
install:
- pip install pep8 pyflakes flake8 coverage
- pip install pep8 pyflakes flake8 coverage Pillow
script:
- make lint
View
@@ -173,3 +173,4 @@
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
OpenTimelineIO bundles ffmpeg_burnins.py, which is available under the MIT License. For details contrib/adapters.
@@ -0,0 +1,89 @@
#
# Copyright 2017 Pixar Animation Studios
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
"""FFMPEG Burnins Adapter"""
import os
import sys
def build_burnins(input_otio):
"""
Generates the burnin objects for each clip within the otio container
:param input_otio: OTIO container
:rtype: [ffmpeg_burnins.Burnins(), ...]
"""
if os.path.dirname(__file__) not in sys.path:
sys.path.append(os.path.dirname(__file__))
import ffmpeg_burnins
key = 'burnins'
burnins = []
for clip in input_otio.each_clip():
# per clip burnin data
burnin_data = clip.media_reference.metadata.get(key)
if not burnin_data:
# otherwise default to global burnin
burnin_data = input_otio.metadata.get(key)
if not burnin_data:
continue
media = clip.media_reference.target_url
if media.startswith('file://'):
media = media[7:]
streams = burnin_data.get('streams')
burnins.append(ffmpeg_burnins.Burnins(media,
streams=streams))
burnins[-1].otio_media = media
burnins[-1].otio_overwrite = burnin_data.get('overwrite')
burnins[-1].otio_args = burnin_data.get('args')
for burnin in burnin_data.get('burnins', []):
align = burnin.pop('align')
function = burnin.pop('function')
if function == 'text':
text = burnin.pop('text')
options = ffmpeg_burnins.TextOptions()
options.update(burnin)
burnins[-1].add_text(text, align, options=options)
elif function == 'frame_number':
options = ffmpeg_burnins.FrameNumberOptions()
options.update(burnin)
burnins[-1].add_frame_numbers(align, options=options)
else:
raise RuntimeError("Unknown function '%s'" % function)
return burnins
def write_to_file(input_otio, filepath):
"""required OTIO function hook"""
for burnin in build_burnins(input_otio):
burnin.render(os.path.join(filepath, burnin.otio_media),
args=burnin.otio_args,
overwrite=burnin.otio_overwrite)
@@ -28,6 +28,13 @@
"execution_scope" : "in process",
"filepath" : "ale.py",
"suffixes" : ["ale"]
},
{
"OTIO_SCHEMA" : "Adapter.1",
"name" : "burnins",
"execution_scope" : "in process",
"filepath" : "burnins.py",
"suffixes" : []
}
]
}
Oops, something went wrong.

0 comments on commit 9e7eeda

Please sign in to comment.