gen_testmedia.sh (2668B)
1 #!/bin/sh 2 # This file is in the public domain. 3 # 4 # Regenerate the media files that the video thumbnail and audio preview 5 # plugins are tested against. They are checked into the repository (and 6 # shipped in the tarball), so you only need this if you want to change 7 # them -- or if you want to convince yourself that they really are 8 # synthetic and carry nobody's copyright. 9 # 10 # Everything here comes out of FFmpeg's lavfi test sources (solid colours, 11 # a box, a sine wave), so the result is not derived from any third party 12 # work. The files are dedicated to the public domain (CC0); see 13 # src/plugins/testdata/README.media. 14 # 15 # Usage: contrib/gen_testmedia.sh [output-directory] 16 set -e 17 18 OUT="${1:-src/plugins/testdata}" 19 FFMPEG="${FFMPEG:-ffmpeg}" 20 21 if ! command -v "$FFMPEG" > /dev/null 2>&1; then 22 echo "$0: $FFMPEG not found" >&2 23 exit 1 24 fi 25 26 # The video changes colour 20s in, and the thumbnailers are expected to 27 # sample around 30s, so a thumbnail of the wrong moment is a thumbnail of 28 # the wrong colour and the test notices. The white box keeps the frames 29 # from being perfectly flat, which the thumbnailers deliberately skip. 30 $FFMPEG -hide_banner -loglevel error -y \ 31 -f lavfi -i "color=c=black:s=160x120:r=5:d=20,drawbox=x=10:y=10:w=24:h=24:color=white:t=fill" \ 32 -f lavfi -i "color=c=red:s=160x120:r=5:d=70,drawbox=x=116:y=76:w=24:h=24:color=white:t=fill" \ 33 -filter_complex "[0:v][1:v]concat=n=2:v=1:a=0[v]" \ 34 -map "[v]" -c:v libtheora -q:v 3 \ 35 "$OUT/thumbnail_pattern.ogv" 36 37 # A 30s tone that changes pitch halfway through, so that a preview taken 38 # from the wrong place is at least in principle detectable. 8kHz mono is 39 # plenty for something that gets re-encoded at 24 kbps. 40 $FFMPEG -hide_banner -loglevel error -y \ 41 -f lavfi -i "sine=f=440:d=15:r=8000" \ 42 -f lavfi -i "sine=f=880:d=15:r=8000" \ 43 -filter_complex "[0:a][1:a]concat=n=2:v=0:a=1[a]" \ 44 -map "[a]" -c:a libvorbis -q:a -2 -ac 1 \ 45 "$OUT/preview_tone.ogg" 46 47 # The same audio in a file that also has a video stream, so that the 48 # preview plugins are exercised on a video container too. 49 $FFMPEG -hide_banner -loglevel error -y \ 50 -f lavfi -i "color=c=black:s=160x120:r=5:d=10,drawbox=x=10:y=10:w=24:h=24:color=white:t=fill" \ 51 -f lavfi -i "color=c=red:s=160x120:r=5:d=20,drawbox=x=116:y=76:w=24:h=24:color=white:t=fill" \ 52 -f lavfi -i "sine=f=440:d=15:r=8000" \ 53 -f lavfi -i "sine=f=880:d=15:r=8000" \ 54 -filter_complex "[0:v][1:v]concat=n=2:v=1:a=0[v];[2:a][3:a]concat=n=2:v=0:a=1[a]" \ 55 -map "[v]" -map "[a]" -c:v libtheora -q:v 3 -c:a libvorbis -q:a -2 -ac 1 \ 56 "$OUT/preview_tone.ogv" 57 58 ls -l "$OUT/thumbnail_pattern.ogv" "$OUT/preview_tone.ogg" "$OUT/preview_tone.ogv"