| #!/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 |