Skip to content

Commit b089864

Browse files
authored
Merge pull request #139 from brarcher/webm
WebM
2 parents 8167ff4 + c1c86b3 commit b089864

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

app/src/main/java/protect/videotranscoder/media/MediaContainer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public enum MediaContainer
1717
FLV("flv", "flv", "video/x-flv", Collections.singletonList(VideoCodec.H264), Arrays.asList(AudioCodec.AAC, AudioCodec.MP3, AudioCodec.NONE)),
1818
MKV("matroska", "mkv", "video/x-matroska", Arrays.asList(VideoCodec.H264, VideoCodec.MPEG4, VideoCodec.MPEG2, VideoCodec.MPEG1), Arrays.asList(AudioCodec.AAC, AudioCodec.MP3, AudioCodec.OPUS, AudioCodec.NONE)),
1919
MP4("mp4", "mp4", "video/mp4", Arrays.asList(VideoCodec.H264, VideoCodec.MPEG4, VideoCodec.MPEG2, VideoCodec.MPEG1), Arrays.asList(AudioCodec.AAC, AudioCodec.MP3, AudioCodec.NONE)),
20+
WEBM("webm", "webm", "video/webm", Arrays.asList(VideoCodec.VP8), Arrays.asList(AudioCodec.OPUS, AudioCodec.VORBIS, AudioCodec.NONE)),
2021
GIF("gif", "gif", "image/gif", Arrays.asList(VideoCodec.GIF), Collections.EMPTY_LIST),
2122

2223
// Audio only

app/src/main/java/protect/videotranscoder/media/VideoCodec.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public enum VideoCodec
2323
MPEG4("mpeg4", "MPEG-4", Collections.EMPTY_LIST, R.string.codecFastGood),
2424
MPEG2("mpeg2video", "MPEG-2", Collections.EMPTY_LIST, R.string.codecFastOk),
2525
MPEG1("mpeg1video", "MPEG-1", Collections.EMPTY_LIST, R.string.codecFastLow),
26+
VP8("libvpx", "VP8", Collections.EMPTY_LIST, null),
2627
GIF("gif", "GIF", Collections.EMPTY_LIST, null),
2728
;
2829

app/src/test/shell/test.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
import json
66
import collections
77
import time
8-
from datetime import datetime
98

109
ASSETS = 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"])
1312
AudioTest = collections.namedtuple("AudioTest", ["filename", "mediaContainer", "formatName", "extension", "audioCodec", "audioCodecName", "audioSampleRate", "audioBitrateK", "audioChannel"])
1413

1514
def 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

3945
def 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

121128
def 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"])
275283
videoTests = []
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"])
283292
audioTests = []

0 commit comments

Comments
 (0)