Skip to content

Commit

Permalink
Merge pull request #139 from brarcher/webm
Browse files Browse the repository at this point in the history
WebM
  • Loading branch information
brarcher authored Oct 27, 2018
2 parents 8167ff4 + c1c86b3 commit b089864
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum MediaContainer
FLV("flv", "flv", "video/x-flv", Collections.singletonList(VideoCodec.H264), Arrays.asList(AudioCodec.AAC, AudioCodec.MP3, AudioCodec.NONE)),
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)),
MP4("mp4", "mp4", "video/mp4", Arrays.asList(VideoCodec.H264, VideoCodec.MPEG4, VideoCodec.MPEG2, VideoCodec.MPEG1), Arrays.asList(AudioCodec.AAC, AudioCodec.MP3, AudioCodec.NONE)),
WEBM("webm", "webm", "video/webm", Arrays.asList(VideoCodec.VP8), Arrays.asList(AudioCodec.OPUS, AudioCodec.VORBIS, AudioCodec.NONE)),
GIF("gif", "gif", "image/gif", Arrays.asList(VideoCodec.GIF), Collections.EMPTY_LIST),

// Audio only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum VideoCodec
MPEG4("mpeg4", "MPEG-4", Collections.EMPTY_LIST, R.string.codecFastGood),
MPEG2("mpeg2video", "MPEG-2", Collections.EMPTY_LIST, R.string.codecFastOk),
MPEG1("mpeg1video", "MPEG-1", Collections.EMPTY_LIST, R.string.codecFastLow),
VP8("libvpx", "VP8", Collections.EMPTY_LIST, null),
GIF("gif", "GIF", Collections.EMPTY_LIST, null),
;

Expand Down
39 changes: 24 additions & 15 deletions app/src/test/shell/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
import json
import collections
import time
from datetime import datetime

ASSETS = os.path.dirname(os.path.realpath(__file__)) + os.sep + "assets"

VideoTest = collections.namedtuple("VideoTest", ["filename", "mediaContainer", "formatName", "extension", "videoCodec", "videoBitrateK", "resolution", "fps", "audioCodec", "audioCodecName", "audioSampleRate", "audioBitrateK", "audioChannel"])
VideoTest = collections.namedtuple("VideoTest", ["filename", "mediaContainer", "formatName", "extension", "videoCodec", "ffmpegVideoCodecName", "videoBitrateK", "resolution", "fps", "audioCodec", "audioCodecName", "audioSampleRate", "audioBitrateK", "audioChannel"])
AudioTest = collections.namedtuple("AudioTest", ["filename", "mediaContainer", "formatName", "extension", "audioCodec", "audioCodecName", "audioSampleRate", "audioBitrateK", "audioChannel"])

def adb(args):
Expand All @@ -19,8 +18,15 @@ def adb(args):
if result != 0:
raise Exception("adb failed with " + str(result) + ": " + str(cmd))

def logcat(sinceTime):
p = subprocess.Popen(["adb", "logcat", "-t", sinceTime], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
def logcatClear():
p = subprocess.Popen(["adb", "logcat", "-c"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
rc = p.wait()
if rc != 0:
raise Exception("logcat failed with " + str(rc) + ": " + stderr)

def logcat():
p = subprocess.Popen(["adb", "logcat", "-d"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
rc = p.wait()
if rc != 0:
Expand All @@ -38,12 +44,13 @@ def pushAsset(filename):

def encodeVideoTest(test, output):
pushAsset(test.filename)
startTime = datetime.now().strftime('%m-%d %H:%M:%S.000')

logcatClear()
encodeVideo(test.filename, output, test.mediaContainer, test.videoCodec, test.videoBitrateK, test.resolution, test.fps, test.audioCodec, test.audioSampleRate, test.audioBitrateK, test.audioChannel)

logs = None
for count in range(1, 300):
logs = logcat(startTime)
logs = logcat()
if "Encode result" in logs:
break
time.sleep(1)
Expand Down Expand Up @@ -120,12 +127,13 @@ def encodeVideo(filename, output, mediaContainer, videoCodec, videoBitrateK, res

def encodeAudioTest(test, output):
pushAsset(test.filename)
startTime = datetime.now().strftime('%m-%d %H:%M:%S.000')

logcatClear()
encodeAudio(test.filename, output, test.mediaContainer, test.audioCodec, test.audioSampleRate, test.audioBitrateK, test.audioChannel)

logs = None
for count in range(1, 300):
logs = logcat(startTime)
logs = logcat()
if "Encode result" in logs:
break
time.sleep(1)
Expand Down Expand Up @@ -246,7 +254,7 @@ def verifyVideoStream(test, stream):

resolution = str(width) + "x" + str(height)

if codecName != test.videoCodec:
if codecName != test.ffmpegVideoCodecName:
raise Exception("Unexpected video codec: '%s' vs '%s'" % (test.videoCodec, codecName))

if avgFrameRate != test.fps:
Expand All @@ -271,13 +279,14 @@ def verifyAudioStream(test, stream):



# VideoTest = collections.namedtuple("VideoTest", ["filename", "mediaContainer", "formatName", "extension", "videoCodec", "videoBitrateK", "resolution", "fps", "audioCodec", "audioCodecName", "audioSampleRate", "audioBitrateK", "audioChannel"])
# VideoTest = collections.namedtuple("VideoTest", ["filename", "mediaContainer", "formatName", "extension", "videoCodec", "ffmpegVideoCodecName", "videoBitrateK", "resolution", "fps", "audioCodec", "audioCodecName", "audioSampleRate", "audioBitrateK", "audioChannel"])
videoTests = []
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "avi", "avi", "avi", "mpeg4", "2000", "360x240", "19", "mp3", "mp3", "22050", "100", "2"))
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "mp4", "mp4", "mp4", "h264", "2000", "360x240", "19", "aac", "aac", "22050", "100", "2"))
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "matroska", "matroska", "mkv", "h264", "2000", "180x120", "24", "aac", "aac", "22050", "50", "1"))
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "flv", "flv", "flv", "h264", "2000", "180x120", "24", "aac", "aac", "22050", "50", "1"))
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "gif", "gif", "gif", "gif", "2000", "360x240", "10", None, None, None, None, None))
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "avi", "avi", "avi", "mpeg4", "mpeg4", "2000", "360x240", "19", "mp3", "mp3", "22050", "100", "2"))
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "mp4", "mp4", "mp4", "h264", "h264", "2000", "360x240", "19", "aac", "aac", "22050", "100", "2"))
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "matroska", "matroska", "mkv", "h264", "h264", "2000", "180x120", "24", "aac", "aac", "22050", "50", "1"))
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "flv", "flv", "flv", "h264", "h264", "2000", "180x120", "24", "aac", "aac", "22050", "50", "1"))
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "webm", "webm", "webm", "libvpx", "vp8", "2000", "180x120", "24", "vorbis", "vorbis", "22050", "50", "2"))
videoTests.append(VideoTest("SampleVideo_360x240_1mb.mp4", "gif", "gif", "gif", "gif", "gif", "2000", "360x240", "10", None, None, None, None, None))

# AudioTest = collections.namedtuple("AudioTest", ["filename", "mediaContainer", "formatName", "extension", "audioCodec", "audioCodecName", "audioSampleRate", "audioBitrateK", "audioChannel"])
audioTests = []
Expand Down

0 comments on commit b089864

Please sign in to comment.