|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +ASSETS="$(dirname $0)/assets" |
| 4 | + |
| 5 | +encode_file() |
| 6 | +{ |
| 7 | + args="" |
| 8 | + for arg in "$@" |
| 9 | + do |
| 10 | + args="${args} $arg" |
| 11 | + done |
| 12 | + |
| 13 | + # Clear the logs, so we know when the encoding is complete |
| 14 | + adb shell logcat -c |
| 15 | + |
| 16 | + echo "Encoding start: ${args}" |
| 17 | + adb shell am start -a "protect.videotranscoder.ENCODE" --ez skipDialog true ${args} |
| 18 | + |
| 19 | + for i in `seq 1 300`; do |
| 20 | + result=$(adb logcat -d | grep VideoTranscoder | grep "Encode result") |
| 21 | + if [ ! -z "${result}" ]; then |
| 22 | + echo "Encoding complete" |
| 23 | + |
| 24 | + if [ ! -z "$(echo ${result} | grep 'Encode result: false')" ]; then |
| 25 | + echo "Encoding failed" |
| 26 | + exit 1 |
| 27 | + fi |
| 28 | + return |
| 29 | + fi |
| 30 | + sleep 1 |
| 31 | + done |
| 32 | + |
| 33 | + echo "Encoding did not complete before timeout" |
| 34 | + exit 1 |
| 35 | +} |
| 36 | + |
| 37 | +pull_file() |
| 38 | +{ |
| 39 | + adb pull "$1" . |
| 40 | +} |
| 41 | + |
| 42 | +remove_file() |
| 43 | +{ |
| 44 | + adb shell rm "$1" |
| 45 | +} |
| 46 | + |
| 47 | +push_asset() |
| 48 | +{ |
| 49 | + adb push "$ASSETS/$1" /sdcard |
| 50 | +} |
| 51 | + |
| 52 | + |
| 53 | +echo "test mp4 -> mp4" |
| 54 | +FILE=SampleVideo_360x240_1mb.mp4 |
| 55 | +OUTPUT=output.mp4 |
| 56 | +push_asset ${FILE} |
| 57 | +encode_file --es inputVideoFilePath "/sdcard/${FILE}" --es outputFilePath /sdcard/${OUTPUT} --es mediaContainer mp4 --es videoCodec h264 --ei videoBitrateK 2000 --es resolution 360x240 --es fps 19 --es audioCodec aac --ei audioSampleRate 22050 --ei audioBitrateK 100 --es audioChannel 2 |
| 58 | +pull_file /sdcard/${OUTPUT} |
| 59 | +remove_file /sdcard/${OUTPUT} |
| 60 | +ffprobe -i ${OUTPUT} |
| 61 | + |
| 62 | +echo "test mp4 -> flv" |
| 63 | +FILE=SampleVideo_360x240_1mb.mp4 |
| 64 | +OUTPUT=output.flv |
| 65 | +push_asset ${FILE} |
| 66 | +encode_file --es inputVideoFilePath "/sdcard/${FILE}" --es outputFilePath /sdcard/${OUTPUT} --es mediaContainer flv --es videoCodec h264 --ei videoBitrateK 2000 --es resolution 360x240 --es fps 19 --es audioCodec aac --ei audioSampleRate 22050 --ei audioBitrateK 100 --es audioChannel 2 |
| 67 | +pull_file /sdcard/${OUTPUT} |
| 68 | +remove_file /sdcard/${OUTPUT} |
| 69 | +ffprobe -i ${OUTPUT} |
| 70 | + |
| 71 | +echo "test mp4 -> mkv" |
| 72 | +FILE=SampleVideo_360x240_1mb.mp4 |
| 73 | +OUTPUT=output.mkv |
| 74 | +push_asset ${FILE} |
| 75 | +encode_file --es inputVideoFilePath "/sdcard/${FILE}" --es outputFilePath /sdcard/${OUTPUT} --es mediaContainer matroska --es videoCodec h264 --ei videoBitrateK 2000 --es resolution 360x240 --es fps 19 --es audioCodec aac --ei audioSampleRate 22050 --ei audioBitrateK 100 --es audioChannel 2 |
| 76 | +pull_file /sdcard/${OUTPUT} |
| 77 | +remove_file /sdcard/${OUTPUT} |
| 78 | +ffprobe -i ${OUTPUT} |
| 79 | + |
| 80 | +echo "test mp4 -> gif" |
| 81 | +FILE=SampleVideo_360x240_1mb.mp4 |
| 82 | +OUTPUT=output.gif |
| 83 | +push_asset ${FILE} |
| 84 | +encode_file --es inputVideoFilePath "/sdcard/${FILE}" --es outputFilePath /sdcard/${OUTPUT} --es mediaContainer gif --es videoCodec gif --ei videoBitrateK 2000 --es resolution 360x240 --es fps 19 |
| 85 | +pull_file /sdcard/${OUTPUT} |
| 86 | +remove_file /sdcard/${OUTPUT} |
| 87 | +ffprobe -i ${OUTPUT} |
| 88 | + |
| 89 | +echo "test mp4 -> mp3" |
| 90 | +FILE=SampleVideo_360x240_1mb.mp4 |
| 91 | +OUTPUT=output.mp3 |
| 92 | +push_asset ${FILE} |
| 93 | +encode_file --es inputVideoFilePath "/sdcard/${FILE}" --es outputFilePath /sdcard/${OUTPUT} --es mediaContainer mp3 --es audioCodec mp3 --ei audioSampleRate 22050 --ei audioBitrateK 100 --es audioChannel 2 |
| 94 | +pull_file /sdcard/${OUTPUT} |
| 95 | +remove_file /sdcard/${OUTPUT} |
| 96 | +ffprobe -i ${OUTPUT} |
| 97 | + |
| 98 | +echo "test mp4 -> ogg" |
| 99 | +FILE=SampleVideo_360x240_1mb.mp4 |
| 100 | +OUTPUT=output.ogg |
| 101 | +push_asset ${FILE} |
| 102 | +encode_file --es inputVideoFilePath "/sdcard/${FILE}" --es outputFilePath /sdcard/${OUTPUT} --es mediaContainer ogg --es audioCodec vorbis --ei audioSampleRate 22050 --ei audioBitrateK 100 --es audioChannel 2 |
| 103 | +pull_file /sdcard/${OUTPUT} |
| 104 | +remove_file /sdcard/${OUTPUT} |
| 105 | +ffprobe -i ${OUTPUT} |
| 106 | + |
| 107 | +echo "test mp4 -> opus" |
| 108 | +FILE=SampleVideo_360x240_1mb.mp4 |
| 109 | +OUTPUT=output.opus |
| 110 | +push_asset ${FILE} |
| 111 | +encode_file --es inputVideoFilePath "/sdcard/${FILE}" --es outputFilePath /sdcard/${OUTPUT} --es mediaContainer opus --es audioCodec libopus --ei audioSampleRate 48000 --ei audioBitrateK 100 --es audioChannel 2 |
| 112 | +pull_file /sdcard/${OUTPUT} |
| 113 | +remove_file /sdcard/${OUTPUT} |
| 114 | +ffprobe -i ${OUTPUT} |
0 commit comments