55import json
66import collections
77import time
8- from datetime import datetime
98
109ASSETS = os .path .dirname (os .path .realpath (__file__ )) + os .sep + "assets"
1110
12- VideoTest = collections .namedtuple ("VideoTest" , ["filename" , "mediaContainer" , "formatName" , "extension" , "videoCodec" , "videoBitrateK" , "resolution" , "fps" , "audioCodec" , "audioCodecName" , "audioSampleRate" , "audioBitrateK" , "audioChannel" ])
11+ VideoTest = collections .namedtuple ("VideoTest" , ["filename" , "mediaContainer" , "formatName" , "extension" , "videoCodec" , "ffmpegVideoCodecName" , " videoBitrateK" , "resolution" , "fps" , "audioCodec" , "audioCodecName" , "audioSampleRate" , "audioBitrateK" , "audioChannel" ])
1312AudioTest = collections .namedtuple ("AudioTest" , ["filename" , "mediaContainer" , "formatName" , "extension" , "audioCodec" , "audioCodecName" , "audioSampleRate" , "audioBitrateK" , "audioChannel" ])
1413
1514def adb (args ):
@@ -19,8 +18,15 @@ def adb(args):
1918 if result != 0 :
2019 raise Exception ("adb failed with " + str (result ) + ": " + str (cmd ))
2120
22- def logcat (sinceTime ):
23- p = subprocess .Popen (["adb" , "logcat" , "-t" , sinceTime ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
21+ def logcatClear ():
22+ p = subprocess .Popen (["adb" , "logcat" , "-c" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
23+ stdout , stderr = p .communicate ()
24+ rc = p .wait ()
25+ if rc != 0 :
26+ raise Exception ("logcat failed with " + str (rc ) + ": " + stderr )
27+
28+ def logcat ():
29+ p = subprocess .Popen (["adb" , "logcat" , "-d" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
2430 stdout , stderr = p .communicate ()
2531 rc = p .wait ()
2632 if rc != 0 :
@@ -38,12 +44,13 @@ def pushAsset(filename):
3844
3945def encodeVideoTest (test , output ):
4046 pushAsset (test .filename )
41- startTime = datetime .now ().strftime ('%m-%d %H:%M:%S.000' )
47+
48+ logcatClear ()
4249 encodeVideo (test .filename , output , test .mediaContainer , test .videoCodec , test .videoBitrateK , test .resolution , test .fps , test .audioCodec , test .audioSampleRate , test .audioBitrateK , test .audioChannel )
4350
4451 logs = None
4552 for count in range (1 , 300 ):
46- logs = logcat (startTime )
53+ logs = logcat ()
4754 if "Encode result" in logs :
4855 break
4956 time .sleep (1 )
@@ -120,12 +127,13 @@ def encodeVideo(filename, output, mediaContainer, videoCodec, videoBitrateK, res
120127
121128def encodeAudioTest (test , output ):
122129 pushAsset (test .filename )
123- startTime = datetime .now ().strftime ('%m-%d %H:%M:%S.000' )
130+
131+ logcatClear ()
124132 encodeAudio (test .filename , output , test .mediaContainer , test .audioCodec , test .audioSampleRate , test .audioBitrateK , test .audioChannel )
125133
126134 logs = None
127135 for count in range (1 , 300 ):
128- logs = logcat (startTime )
136+ logs = logcat ()
129137 if "Encode result" in logs :
130138 break
131139 time .sleep (1 )
@@ -246,7 +254,7 @@ def verifyVideoStream(test, stream):
246254
247255 resolution = str (width ) + "x" + str (height )
248256
249- if codecName != test .videoCodec :
257+ if codecName != test .ffmpegVideoCodecName :
250258 raise Exception ("Unexpected video codec: '%s' vs '%s'" % (test .videoCodec , codecName ))
251259
252260 if avgFrameRate != test .fps :
@@ -271,13 +279,14 @@ def verifyAudioStream(test, stream):
271279
272280
273281
274- # VideoTest = collections.namedtuple("VideoTest", ["filename", "mediaContainer", "formatName", "extension", "videoCodec", "videoBitrateK", "resolution", "fps", "audioCodec", "audioCodecName", "audioSampleRate", "audioBitrateK", "audioChannel"])
282+ # VideoTest = collections.namedtuple("VideoTest", ["filename", "mediaContainer", "formatName", "extension", "videoCodec", "ffmpegVideoCodecName", " videoBitrateK", "resolution", "fps", "audioCodec", "audioCodecName", "audioSampleRate", "audioBitrateK", "audioChannel"])
275283videoTests = []
276- videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "avi" , "avi" , "avi" , "mpeg4" , "2000" , "360x240" , "19" , "mp3" , "mp3" , "22050" , "100" , "2" ))
277- videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "mp4" , "mp4" , "mp4" , "h264" , "2000" , "360x240" , "19" , "aac" , "aac" , "22050" , "100" , "2" ))
278- videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "matroska" , "matroska" , "mkv" , "h264" , "2000" , "180x120" , "24" , "aac" , "aac" , "22050" , "50" , "1" ))
279- videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "flv" , "flv" , "flv" , "h264" , "2000" , "180x120" , "24" , "aac" , "aac" , "22050" , "50" , "1" ))
280- videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "gif" , "gif" , "gif" , "gif" , "2000" , "360x240" , "10" , None , None , None , None , None ))
284+ videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "avi" , "avi" , "avi" , "mpeg4" , "mpeg4" , "2000" , "360x240" , "19" , "mp3" , "mp3" , "22050" , "100" , "2" ))
285+ videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "mp4" , "mp4" , "mp4" , "h264" , "h264" , "2000" , "360x240" , "19" , "aac" , "aac" , "22050" , "100" , "2" ))
286+ videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "matroska" , "matroska" , "mkv" , "h264" , "h264" , "2000" , "180x120" , "24" , "aac" , "aac" , "22050" , "50" , "1" ))
287+ videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "flv" , "flv" , "flv" , "h264" , "h264" , "2000" , "180x120" , "24" , "aac" , "aac" , "22050" , "50" , "1" ))
288+ videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "webm" , "webm" , "webm" , "libvpx" , "vp8" , "2000" , "180x120" , "24" , "vorbis" , "vorbis" , "22050" , "50" , "2" ))
289+ videoTests .append (VideoTest ("SampleVideo_360x240_1mb.mp4" , "gif" , "gif" , "gif" , "gif" , "gif" , "2000" , "360x240" , "10" , None , None , None , None , None ))
281290
282291# AudioTest = collections.namedtuple("AudioTest", ["filename", "mediaContainer", "formatName", "extension", "audioCodec", "audioCodecName", "audioSampleRate", "audioBitrateK", "audioChannel"])
283292audioTests = []
0 commit comments