Skip to content

Commit bb9eb9b

Browse files
author
Clement Champetier
committed
pyconcat: check type of streams to rewrap
Raise runtimeError if the streams have different type.
1 parent 912a3b7 commit bb9eb9b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

app/pyConcat/pyconcat.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from pyAvTranscoder import avtranscoder as av
44

5+
from sets import Set
6+
57

68
# Get command line arguments
79
args = []
@@ -30,20 +32,23 @@
3032
logger = av.Logger().setLogLevel(av.AV_LOG_QUIET)
3133
av.preloadCodecsAndFormats()
3234

33-
# output
34-
outputFile = av.OutputFile( args.outputFileName );
35-
35+
streamTypeToConcat = Set()
3636
# get all input files
3737
inputFiles = []
38-
streamTypeToConcat = 0
3938
for input in args.inputs:
4039
inputFile = av.InputFile(input)
41-
streamTypeToConcat = inputFile.getStream(0).getProperties().getStreamType()
40+
streamTypeToConcat.add( inputFile.getStream(0).getProperties().getStreamType() )
4241
inputFiles.append(inputFile)
4342

44-
if streamTypeToConcat == av.AVMEDIA_TYPE_VIDEO:
43+
# Check type of streams to rewrap
44+
if len(streamTypeToConcat) > 1:
45+
raise RuntimeError("Cannot concatenate streams of different type.")
46+
47+
# Create the output
48+
outputFile = av.OutputFile( args.outputFileName );
49+
if av.AVMEDIA_TYPE_VIDEO in streamTypeToConcat:
4550
outputFile.addVideoStream( inputFiles[-1].getStream(0).getVideoCodec() )
46-
elif streamTypeToConcat == av.AVMEDIA_TYPE_AUDIO:
51+
elif av.AVMEDIA_TYPE_AUDIO in streamTypeToConcat:
4752
outputFile.addVideoStream( inputFiles[-1].getStream(0).getAudioCodec() )
4853

4954
### process

0 commit comments

Comments
 (0)