Skip to content

Add python app pyProcessor #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions app/python/pyProcessor/pyProcessor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import sys

from AvTranscoder import AvTranscoder

def parseConfigFile( inputConfigFile, transcoder ):
"""
Parse a config file with for each lines:
<media_file>=<stream_index>.<substream_index>:<profile_name>
* The substream index is not necessary.
* Dummy streams (video and audio) are not supported.
* Offset is not supported.
"""
file = open( inputConfigFile, 'r' )
for line in file:
line = line.strip( '\n' )

name = line.split( '=' )
filename = name[0]

params = name[1].split( ':' )
streamIndex = int( params[0] )
subStreamIndex = -1 if '.' not in params[0] else params[0].split( '.' )[0]
profileName = '' if not params[1] else params[1]

transcoder.add( filename, streamIndex, subStreamIndex, profileName )

if len(sys.argv) < 3:
print "pyProcessor requires an input config file and an output media filename"
exit(1)

# create Transcoder
ouputFile = AvTranscoder.OutputFile( sys.argv[2] )
transcoder = AvTranscoder.Transcoder( ouputFile )

# parse configuration file
inputConfigFile = sys.argv[1]
parseConfigFile( inputConfigFile, transcoder )

# initialize Transcoder
transcoder.setProcessMethod( AvTranscoder.eProcessMethodLongest )
transcoder.init()

# Process transcode
progress = AvTranscoder.ProgressListener()
transcoder.process( progress )