How to load a movie file into blender, and re-export it as a sequence of images, headlessly (via .bpy/python script) Trying to get to grips with the abilities of blender when used purely as a python library (without any GUI interactions). (Forgive my lack of knowledge and misuse of words)

The code examples and documentation I am finding seem geared towards scripts to apply when content is already present within the blender GUI. (e.g. Extract sequence of frames from imported MP4 - scripted?)

Does an example exist in documentation for loading external files into a blender virtual stage?
e.g. 1 picture node and 1 video node
and (secondarily) exporting the rendered output (e.g. video with an image overlaid) as an image sequence.

I've been looking through https://www.blender.org/api/blender_python_api_2_72_release/info_quickstart.html and http://wiki.blender.org/index.php/Dev:Py/Scripts but I haven't been able so far to find a good starting point for my knowledge level.
This script accepts the movie file and output directory as command line arguments, then loads the video file as a video sequence editor (VSE) clip and renders it out as frames (by default as PNG, change if needed).

It automatically sets the render resolution and frame duration according to the video file.

import bpy, sys

# Take movie clip filepath and output directory as command line arguments
movieFilePath, OutputPath = sys.argv[-2:]

S  = bpy.context.scene
mc = bpy.data.movieclips.load( movieFilePath )

# Set render resolution to match movie clip
S.render.resolution_x          = mc.size[0]
S.render.resolution_y          = mc.size[1]
S.render.resolution_percentage = 100

# Set number of frames to match movie clip length
S.frame_start = 0
S.frame_end   = mc.frame_duration

# Set render format and output folder
S.render.image_settings.file_format = 'PNG'
S.render.filepath                   = OutputPath

# Load clip to sequencer
se = bpy.context.scene.sequence_editor_create()
se.sequences.new_clip( "MyClip", mc, 0, 0 )

# Render animation to create image sequence
bpy.ops.render.render( animation = True, write_still = True )


To use it, save the script file, then run blender from the command line and provide the filepath and output directory as arguments:

blender -b -P movie_to_images.py -- C:/MyMovie.avi C:/OutputFolder/