Skip to content

Commit b656a26

Browse files
author
Clement Champetier
committed
App: deploy pyprocessor
pyprocessor uses argparse.
1 parent cf64d33 commit b656a26

File tree

4 files changed

+62
-46
lines changed

4 files changed

+62
-46
lines changed

app/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ add_subdirectory(avPlay)
55
add_subdirectory(avProcessor)
66

77
# Python apps
8-
add_subdirectory(pyThumbnail)
8+
add_subdirectory(pyProcessor)
9+
add_subdirectory(pyThumbnail)

app/pyProcessor/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### python/pyProcessor
2+
3+
# Install app
4+
install(
5+
FILES "pyprocessor.py"
6+
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
7+
DESTINATION "share/python"
8+
)

app/pyProcessor/pyProcessor.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

app/pyProcessor/pyprocessor.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import sys
2+
import argparse # python2.7+
3+
4+
from pyAvTranscoder import avtranscoder as av
5+
6+
7+
def parseConfigFile( inputConfigFile, transcoder ):
8+
file = open( inputConfigFile, 'r' )
9+
for line in file:
10+
line = line.strip( '\n' )
11+
12+
filename, operation = line.split( '=' )
13+
14+
streamIndexes, profileName = operation.split( ':' )
15+
if "." in streamIndexes:
16+
streamIndex, subStreamIndex = map(int, streamIndexes.split( '.' ))
17+
else:
18+
streamIndex = int(streamIndexes)
19+
subStreamIndex = -1
20+
21+
transcoder.add( filename, streamIndex, subStreamIndex, profileName )
22+
23+
24+
# Create command-line interface
25+
parser = argparse.ArgumentParser(
26+
prog='pythumbnail',
27+
description='''Generate jpeg thumbnail from video/image.''',
28+
)
29+
30+
# requirements
31+
parser.add_argument('configFileName', help='The config file will be parsed by foloowing this pattern: <media_file>=<stream_index><.substream_index>:<profile_name> \nGenerated streams (video and audio) and offset are not supported.')
32+
parser.add_argument('outputFileName', help='The output media file.')
33+
# Parse command-line
34+
args = parser.parse_args()
35+
36+
# setup avtranscoder
37+
logger = av.Logger().setLogLevel(av.AV_LOG_QUIET)
38+
av.preloadCodecsAndFormats()
39+
40+
# create Transcoder
41+
ouputFile = av.OutputFile( args.outputFileName )
42+
transcoder = av.Transcoder( ouputFile )
43+
44+
# parse configuration file
45+
parseConfigFile( args.configFileName, transcoder )
46+
47+
# initialize Transcoder
48+
transcoder.setProcessMethod( av.eProcessMethodLongest )
49+
50+
# Process transcode
51+
progress = av.ConsoleProgress()
52+
transcoder.process( progress )

0 commit comments

Comments
 (0)