Skip to content

Instantly share code, notes, and snippets.

@hvrauhal
Created April 15, 2020 10:09
Show Gist options
  • Save hvrauhal/d6c1d81e632ccb288d40e9e33d3c8184 to your computer and use it in GitHub Desktop.
Save hvrauhal/d6c1d81e632ccb288d40e9e33d3c8184 to your computer and use it in GitHub Desktop.
Generate video sample files suitable for Android Emulator testing
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# Audio generation
python3 - << EOF
import subprocess
sounds = [
'Start playing',
'30 seconds',
'1 minute',
'1 minute 30 seconds',
'2 minutes',
'2 minutes 30 seconds',
'3 minutes',
'3 minutes 30 seconds',
'4 minutes',
'4 minutes 30 seconds'
]
for v, i in enumerate(sounds):
filename=f'sample_{v:02}_unpadded.aiff'
out_filename=f'sample_{v:02}.wav'
subprocess.run(['say', '-v', 'Ava', i, '-o', filename])
subprocess.run(['ffmpeg', '-y', '-i', filename, '-filter','apad=whole_dur=30', out_filename])
EOF
sox sample*.wav out.wav
rm sample*wav
# Video generation
#
# -vprofile baseline to support playback in android emulator https://stackoverflow.com/questions/4910222/what-formats-of-video-will-play-in-emulator/13030509#13030509
ffmpeg -y -i out.wav -c:a aac -f lavfi -i testsrc2=duration=300:size=1280x720:rate=30 -vcodec libx264 -vprofile baseline -tune animation -crf 41 test_1280_16_9.mp4
ffmpeg -y -i out.wav -c:a aac -f lavfi -i testsrc2=duration=300:size=960x720:rate=30 -vcodec libx264 -vprofile baseline -tune animation -crf 41 test_960_3_4.mp4
@hvrauhal
Copy link
Author

ffmpeg -i [original_source.mp4] -i [overlay] -i [audio_source] -filter_complex \
"[0:v]scale=960:720[bg];[bg][1:v]overlay=0:0" -vcodec libx264 -vprofile baseline \
-tune animation -map 2:a:0 -t 00:3:10 -crf 41 -aspect 960:720 out_4_3.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment