To use the FX SDK for Python, you must have
If you use the standard way to manage your project's dependencies using a requirements.txt file and virtual environments, then add "fx-python-sdk" to your project's dependencies and install it.
$ your-virtualenv/bin/python setup.py install -r ./requirements.txt
An alternative is to download and install the the FX SDK for Python manually.
The latest version can always be found at https://cdn.impossible.io/sdk/python/fx-python-sdk-LATEST.tar.gz
You can the unpack it and install it via python setup.py install.
$ wget https://cdn.impossible.io/sdk/python/fx-python-sdk-LATEST.tar.gz
$ tar xvfz fx-python-sdk-latest.tar.gz
$ (cd fx-python-sdk-{version} && python2.7 setup.py install)
import impossible_fx
# FX_API_KEY and FX_API_SECRET should come from a configuration source like
# environment variables.
svc = impossible_fx.ProjectService(region="us-west-2", auth=(FX_API_KEY, FX_API_SECRET))
The project service client always requires you to connect to a particular region where your project data is hosted and always need authentication. For a list of supported regions, see list of regions.
If you have dynamic movies in your account that you either created using the online editor or programmatically using the project service API, then you can render the movies. Rendering movies does not require authentication. Specifying a region is optional for the render service.
from impossible_fx import RenderService
render = RenderService()
# or:
render = RenderService(region="ap-southeast-2")
FXError is the most common exception that you'll experience when using the SDK for Python. This exception represents an error response from an Impossible FX service. For some cases, a subclass of FXError will be thrown to allow developers fine grained control over handling error cases through try-except blocks.
svc = impossible_fx.ProjectService(region="eu-west-1", auth=(..., ...))
project = svc.create_project("PythonTest")
svc = impossible_fx.ProjectService(region="eu-west-1", auth=(..., ...))
project = svc.create_project("PythonTest")
with open("/tmp/mymovie.mp4") as f:
project.upload_asset("movie.mp4", f)
svc = impossible_fx.RenderService()
render_url = svc.get_render_url(
project_id="...",
movie_name="mymovie", params=dict(
param1="Hello there!",
param2="female"))
print render_url.url
render_result = svc.render_to_s3(
project_id="...",
movie_name="...",
params=dict(
mytext="Hello there!",),
async=False,
format="mp4",
bucket="...",
filename="test/testmovie.mp4",
type="s3",
access_key_id="...",
secret_access_key="...",
content_type="video/mp4",
acl="public-read",
reduced_redundancy=True,
)
print render_result
from impossible_fx import ProjectService, SDL
svc = impossible_fx.ProjectService(region="eu-west-1", auth=(...))
project = svc.get_project("...")
video_params = SDL.VideoParams(width=640, height=360)
stream_params = SDL.StreamParams(vparams=video_params)
red = SDL.Color(red=255, alpha=255)
background = SDL.ImageProvider(type=SDL.ImageProvider.emptyimage, color=red)
background_track = SDL.VisualTrack(content=background)
green = SDL.Color(green=255, alpha=255)
text = SDL.ImageProvider(type=SDL.ImageProvider.textsimple, fontsize=50, color=green, text=SDL.StringVariable(type=SDL.StringVariable.map, key="textblock1"))
foreground_track = SDL.VisualTrack(content=text)
scenes = SDL.Scene(numframes=100, tracks=[background_track, foreground_track])
movie = SDL.Movie(params=stream_params, scenes=[scenes])
print project.create_movie("mymovie", movie)
Open generated Class and Method Reference.
Terms of Use | © 2017, Impossible Software, or its affiliates.