diff options
author | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2011-06-30 19:47:21 +0159 |
---|---|---|
committer | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2011-06-30 19:47:21 +0159 |
commit | f1ce327a37be2edd85a7b3f59beed0b55d70bb2f (patch) | |
tree | 5e0c20d123df39761b8d97248867378ee3fc327c | |
download | mmtest-f1ce327a37be2edd85a7b3f59beed0b55d70bb2f.tar.gz |
Import initial version of the test
-rwxr-xr-x | creator/create-testfiles | 104 | ||||
-rw-r--r-- | mmtest/AndroidManifest.xml | 11 | ||||
-rw-r--r-- | mmtest/src/org/linaro/mmtest/MultimediaTest.java | 134 |
3 files changed, 249 insertions, 0 deletions
diff --git a/creator/create-testfiles b/creator/create-testfiles new file mode 100755 index 0000000..94b7416 --- /dev/null +++ b/creator/create-testfiles @@ -0,0 +1,104 @@ +#!/bin/sh +# This script takes any video file as input, and produces output files +# containing transcodes of the file to any codec Android is supposed +# to support. +# +# List of supported codecs: +# http://developer.android.com/guide/appendix/media-formats.html + +if [ "$#" -lt 1 ]; then + echo "Usage: $0 InputFile" + exit 1 +fi +if ! which ffmpeg &>/dev/null; then + echo "Install ffmpeg >= 0.8 and put it in your PATH" + exit 2 +fi +if ! which mplayer &>/dev/null; then + echo "Install mplayer" + exit 3 +fi +if ! which sox &>/dev/null; then + echo "Install sox" + exit 4 +fi + +IN="$1" + +# ================ +# == Audio-only == +# ================ +# AAC audio +# Maximum supported - 160k, 48k sample rate +ffmpeg -y -i "$IN" -vn -acodec libfaac -ab 160k -ar 48000 -ac 2 test-AAC-Stereo-96k.m4a +# Minimum supported - 8k sample rate, low bitrate +ffmpeg -y -i "$IN" -vn -acodec libfaac -strict experimental -ab 32k -ar 8000 -ac 1 test-AAC-Mono-8k.m4a +# FIXME we probably want to add an He-AACv2 sample when a free encoder +# becomes available +# Non-free encoder for testing could be built with +# http://tipok.org.ua/ru/node/17 + +# AMR +# Done after WAV because ffmpeg doesn't support AMR directly + +# FLAC (Android 3.1+) +ffmpeg -y -i "$IN" -vn -acodec flac -ac 2 -ar 44100 test-flac.flac + +# MP3 +ffmpeg -y -i "$IN" -vn -acodec libmp3lame -ab 64k test-MP3.mp3 + +# We can't create a Midi file from a recording, so we're skipping this + +# Ogg Vorbis +ffmpeg -y -i "$IN" -vn -acodec libvorbis -f ogg -ab 64k test-Vorbis.ogg + +# PCM/WAVE +mplayer "$IN" -benchmark -vc null -vo null -ao pcm:fast:waveheader:file=test-PCM.wav +# 8bit +sox -S test-PCM.wav -b 8 test-PCM8.wav +# 16bit +sox -S test-PCM.wav -b 16 test-PCM16.wav +# The original format is undefined -- could be either 8 or 16 bit depending on the input. +# Let's dispose of it... +rm -f test-PCM.wav + +# AMR +sox -S test-PCM16.wav -c 1 -r 8000 -t amr-nb test-AMR-NB.3gp +# FIXME we probably want to add an AMR-WB sample when a free encoder +# becomes available +# Non-free encoder for testing could be built with +# http://www.penguin.cz/~utx/amr + +# ================ +# == Video-only == +# ================ +# H.263 +ffmpeg -y -i "$IN" -vcodec h263 -s cif -r 25 -vb 768000 -an -f 3gp test-H.263.3gp + +# H.264 AVC Baseline Profile +ffmpeg -y -i "$IN" -vcodec libx264 -vb 1024000 -vpre libx264-baseline -an -f mp4 test-H.264.m4v + + +# MPEG-4 SP +ffmpeg -y -i "$IN" -vcodec mpeg4 -vb 768000 -an -f mp4 test-MPEG4_SP.mp4 + +# VP8 +ffmpeg -y -i "$IN" -vcodec libvpx -vb 768000 -an -f webm test-VP8.webm + + +# ========================== +# == Combined Audio/Video == +# ========================== +# H.263 + AAC in a 3gp container +ffmpeg -y -i "$IN" -vcodec h263 -s cif -r 25 -vb 768000 -acodec libfaac -ac 1 -ar 8000 -ab 32000 -f 3gp test-H.263-AAC.3gp + +# H.264 AVC Baseline + AAC in an mp4 container +ffmpeg -y -i "$IN" -vcodec libx264 -vb 1024000 -vpre libx264-baseline -acodec aac -strict experimental -ab 96000 -f mp4 test-H.264-AAC.mp4 +# Same thing at a much higher resolution and bitrate +ffmpeg -y -i "$IN" -s hd1080 -vcodec libx264 -vb 2048000 -vpre libx264-baseline -acodec aac -strict experimental -ab 96000 -f mp4 test-H.264-AAC.mp4 + +# MPEG-4 SP + MP3 in an mp4 container +ffmpeg -y -i "$IN" -vcodec mpeg4 -vb 768000 -acodec libmp3lame -ab 64000 -f mp4 test-MPEG4-MP3.mp4 + +# VP8 + Vorbis in a WebM container (Android 2.3.3+) +ffmpeg -y -i "$IN" -vcodec libvpx -vb 1024000 -vpre libvpx-360p -f webm -acodec libvorbis -ab 48000 test-VP8-Vorbis.webm diff --git a/mmtest/AndroidManifest.xml b/mmtest/AndroidManifest.xml new file mode 100644 index 0000000..36bca75 --- /dev/null +++ b/mmtest/AndroidManifest.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.linaro.mmtest"> + <application android:label="Multimedia Test"> + <activity android:name="MultimediaTest" android:theme="@android:style/Theme.NoTitleBar" android:screenOrientation="landscape" android:configChanges="orientation"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + </application> +</manifest> diff --git a/mmtest/src/org/linaro/mmtest/MultimediaTest.java b/mmtest/src/org/linaro/mmtest/MultimediaTest.java new file mode 100644 index 0000000..a0c5be7 --- /dev/null +++ b/mmtest/src/org/linaro/mmtest/MultimediaTest.java @@ -0,0 +1,134 @@ +package org.linaro.mmtest; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Build; +import android.view.Window; +import android.util.Log; +import android.media.AudioManager; +import android.media.MediaPlayer; +import android.media.MediaPlayer.OnCompletionListener; +import android.view.SurfaceView; + +import java.util.List; + +public class MultimediaTest extends Activity implements android.media.MediaPlayer.OnCompletionListener,android.media.MediaPlayer.OnErrorListener,android.media.MediaPlayer.OnInfoListener { + private static final String TAG = "MultimediaTest"; + private int currentTest = -1; + private MediaPlayer mp; + private String failure; + private final Test[] tests = { + // Audio Codecs + new Test("test-AAC-Stereo-96k.m4a", "AAC Stereo 96k", false), + new Test("test-AAC-Mono-8k.m4a", "AAC Mono 8k", false), + new Test("test-AMR-NB.3gp", "AMR-NB", false), + new Test("test-flac.flac", "FLAC", false, 12 /*android.os.Build.HONEYCOMB_MR1*/), + new Test("test-MP3.mp3", "MP3", false), + new Test("test-Vorbis.ogg", "Ogg Vorbis", false), + new Test("test-PCM8.wav", "PCM 8-Bit", false), + new Test("test-PCM16.wav", "PCM 16-Bit", false), + + // Video Codecs + new Test("test-H.263.3gp", "H.263"), + new Test("test-H.264.m4v", "H.264"), + new Test("test-MPEG4_SP.mp4", "MPEG-4 SP"), + new Test("test-VP8.webm", "VP8"), + + // Mixed A/V + new Test("test-H.263-AAC.3gp", "3GP(H.263/AAC)"), + new Test("test-H.264-AAC.mp4", "MP4(H.264/AAC)"), + new Test("test-H.264-AAC.mp4", "HD-MP4(H.264/AAC)"), + new Test("test-MPEG4-MP3.mp4", "MP4(MPEG4/MP3)"), + new Test("test-VP8-Vorbis.webm", "WebM(VP8/Vorbis)", true, 10 /*android.os.Build.GINGERBREAD_MR1*/) + }; + + class Test { + public String filename; + public String name; + public boolean hasVideo; + public int minVersion; + + public Test(String pFilename, String pName, boolean pHasVideo, int pMinVersion) { + filename = pFilename; + name = pName; + hasVideo = pHasVideo; + minVersion = pMinVersion; + } + + public Test(String pFilename, String pName, boolean pHasVideo) { + this(pFilename, pName, pHasVideo, 0); + } + + public Test(String pFilename, String pName) { + this(pFilename, pName, true, 0); + } + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Log.v(TAG, "Starting tests"); + + SurfaceView sv=new SurfaceView(this); + setContentView(sv); + + mp=new MediaPlayer(); + mp.setOnCompletionListener(this); + mp.setOnErrorListener(this); + mp.setOnInfoListener(this); + mp.setAudioStreamType(android.media.AudioManager.STREAM_MUSIC); + mp.setDisplay(sv.getHolder()); + + runNextTest(); + } + + public void runNextTest() { + failure = ""; + if(++currentTest > tests.length) { + Log.v(TAG, "Tests completed"); + finish(); + } + Test t=tests[currentTest]; + if(t.minVersion > android.os.Build.VERSION.SDK_INT) { + Log.i(TAG, "SKIP:" + t.name + ":Not expected to pass on this version of Android"); + runNextTest(); + return; + } + Log.v(TAG, "Running test " + t.name); + mp.reset(); + try { + mp.setDataSource("/sdcard/mmtest/" + t.filename); + mp.prepare(); + } catch(java.io.IOException e) { + Log.e(TAG, "ERR:" + tests[currentTest].name + ":test:IO Error - test file seems to be missing: /sdcard/mmtest/" + t.filename); + runNextTest(); + return; + } + if((mp.getVideoHeight() == 0) ^ t.hasVideo) + Log.i(TAG, "PASS:" + tests[currentTest].name + ":sanityCheck:Test and Player agree about whether or not the content has a video part"); + else + Log.i(TAG, "FAIL:" + tests[currentTest].name + ":sanityCheck:Test and Player disagree about whether or not the content has a video part"); + mp.start(); + } + + @Override + public void onCompletion(MediaPlayer mp) { + if(failure.length() == 0) + Log.i(TAG, "PASS:" + tests[currentTest].name + ":playback"); + else + Log.i(TAG, "FAIL:" + tests[currentTest].name + ":playback:" + failure); + runNextTest(); + } + + @Override + public boolean onError(MediaPlayer mp, int what, int extra) { + failure = "Got error code " + Integer.toString(what) + "/" + Integer.toString(extra); + return false; // call onCompletion + } + + @Override + public boolean onInfo(MediaPlayer mp, int what, int extra) { + Log.i(TAG, "NOTE:" + tests[currentTest].name + ":playback:MediaPlayer sent info " + Integer.toString(what) + "/" + Integer.toString(extra)); + return true; + } +} |