-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
110 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule fixtures
updated
48 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,12 @@ | |
# Copyright (C) 2023 Andrew Wason | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
# Create a colored "testsrc" video/image asset, with no audio | ||
|
||
BASE=${BASH_SOURCE%/*} | ||
|
||
usage="$0 <outputdir> <png|nut>:[[color]:[WxH]:[framerate]:[duration]]" | ||
IFS=: read -r TYPE COLOR SIZE FRAMERATE DURATION <<< $2 | ||
usage="$0 <outputdir> <png|mp4>~[[color]~[WxH]~[framerate]~[duration]]" | ||
IFS='~' read -r TYPE COLOR SIZE FRAMERATE DURATION <<< $2 | ||
|
||
COLOR=${COLOR:-red} | ||
SIZE=${SIZE:-640x360} | ||
|
@@ -16,18 +18,18 @@ mkdir -p "$1" | |
|
||
|
||
case ${TYPE:?$usage} in | ||
nut) | ||
mp4) | ||
OUTPUT=${1:?$usage}/${COLOR}-${SIZE}-${FRAMERATE}fps-${DURATION}s.${TYPE} | ||
if [ ! -f "${OUTPUT}" ]; then | ||
echo Creating ${OUTPUT} | ||
ffmpeg -f lavfi -i "testsrc=duration=${DURATION}:size=${SIZE}:rate=${FRAMERATE}:decimals=2,drawbox=color=${COLOR}:t=ih/16,drawtext=text=${COLOR} f%{frame_num}:x=w/10:y=x/dar:shadowx=3:shadowy=3:fontsize=h/3.75:[email protected]:fontfile=${BASE}/JetBrainsMono-Regular.ttf" -f nut -vcodec ffv1 -g 1 -level 3 -pix_fmt rgb32 -framerate ${FRAMERATE} -y "${OUTPUT}" || exit 1 | ||
ffmpeg -f lavfi -i "testsrc=duration=${DURATION}:size=${SIZE}:rate=${FRAMERATE}:decimals=2,drawbox=color=${COLOR}:t=ih/16,drawtext=text=${COLOR} f%{frame_num}:x=w/10:y=x/dar:shadowx=3:shadowy=3:fontsize=h/3.75:[email protected]:fontfile=${BASE}/JetBrainsMono-Regular.ttf" -f mp4 -vcodec libx264 -preset veryslow -qp 0 -y "${OUTPUT}" || exit 1 | ||
fi | ||
;; | ||
png) | ||
OUTPUT=${1:?$usage}/${COLOR}-${SIZE}.${TYPE} | ||
if [ ! -f "${OUTPUT}" ]; then | ||
echo Creating ${OUTPUT} | ||
ffmpeg -f lavfi -i "smptebars=duration=1:size=${SIZE}:rate=1,drawbox=color=${COLOR}:t=ih/16,drawtext=text=${COLOR}:x=w/10:y=x/dar:shadowx=3:shadowy=3:fontsize=h/3.75:[email protected]:fontfile=${BASE}/JetBrainsMono-Regular.ttf" -r 1 -vframes 1 -c:v png -y "${OUTPUT}" || exit 1 | ||
ffmpeg -f lavfi -i "color=color=${COLOR}:duration=1:size=${SIZE}:rate=1,drawtext=text=${COLOR}:x=w/10:y=x/dar:shadowx=3:shadowy=3:fontsize=h/3.75:[email protected]:fontfile=${BASE}/JetBrainsMono-Regular.ttf" -r 1 -vframes 1 -c:v png -y "${OUTPUT}" || exit 1 | ||
fi | ||
;; | ||
*) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (C) 2024 Andrew Wason | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
# Transcode a segment of a video, with timestamps overlayed | ||
|
||
BASE=${BASH_SOURCE%/*} | ||
|
||
usage="$0 <sourcevideo> <outputvideo> <filters> <framerate> <starttime> <endtime>" | ||
SOURCE=${1:?$usage} | ||
OUTPUT=${2:?$usage} | ||
FILTERS=${3:?$usage} | ||
FRAMERATE=${4:?$usage} | ||
STARTTIME=${5:?$usage} | ||
ENDTIME=${6:?$usage} | ||
|
||
printf -v TEXT "'%s\n%s'" "f%{frame_num}" "t%{pts\:hms}" | ||
ffmpeg -ss ${STARTTIME} -to ${ENDTIME} -i "${SOURCE}" -vf "${FILTERS},framerate=${FRAMERATE},drawtext=text=${TEXT}:x=0:y=x/dar:shadowx=3:shadowy=3:fontsize=h/6:[email protected]:fontfile=${BASE}/JetBrainsMono-Regular.ttf" -f mp4 -vcodec libx264 -preset veryslow -qp 0 -codec:a aac -ac 2 -y "${OUTPUT}" || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (C) 2024 Andrew Wason | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
|
||
BASE=${BASH_SOURCE%/*} | ||
usage="$0 <sourcevideodir>" | ||
|
||
SOURCEDIR=${1:-} | ||
|
||
# Create a colored "testsrc" video/image asset, with no audio | ||
for ASSET in 'mp4~blue~320x180~30~3' 'mp4~green~320x180~15~3' 'mp4~red~320x180~15~8' 'mp4~red~640x360~30~4' 'mp4~yellow~320x180~15~3' 'png~red~160x120'; do | ||
${BASE}/create-asset.sh "${BASE}/../tests/fixtures/assets" "${ASSET}" | ||
done | ||
|
||
# Download source videos: | ||
# bbb_sunflower_1080p_30fps_normal.mp4 | ||
# https://download.blender.org/demo/movies/BBB/bbb_sunflower_1080p_30fps_normal.mp4.zip | ||
# ed_hd.avi | ||
# https://archive.org/download/ElephantsDream/ed_hd.avi | ||
# cosmos_laundromat_2k.mp4 | ||
# https://pillar.blender.cloud/p/cosmos-laundromat/58b00b1b49932b2881e00757 | ||
|
||
# Blender videos used under CC By 4.0 license | ||
# https://creativecommons.org/licenses/by/4.0/ | ||
# Trimmed, transcoded, resized, cropped and overlayed with timecode. | ||
# https://studio.blender.org/films/ | ||
|
||
if [ -f "${SOURCEDIR}/ed_hd.avi" ]; then | ||
${BASE}/encode-asset.sh "${SOURCEDIR}/ed_hd.avi" "${BASE}/../tests/fixtures/assets/ednotsafe-320x180-15fps-1.53s.mp4" scale=320x180 15 2:48.458 2:50.041 | ||
${BASE}/encode-asset.sh "${SOURCEDIR}/ed_hd.avi" "${BASE}/../tests/fixtures/assets/edquestions-320x180-15fps-2.4s.mp4" scale=320x180 15 7:00.791 7:03.249 | ||
${BASE}/encode-asset.sh "${SOURCEDIR}/ed_hd.avi" "${BASE}/../tests/fixtures/assets/edjustforyou-320x180-15fps-5.2s.mp4" scale=320x180 15 8:16.416 8:21.666 | ||
fi | ||
|
||
if [ -f "${SOURCEDIR}/cosmos_laundromat_2k.mp4" ]; then | ||
${BASE}/encode-asset.sh "${SOURCEDIR}/cosmos_laundromat_2k.mp4" "${BASE}/../tests/fixtures/assets/cosmoswolf-320x180-15fps-4.1s.mp4" 'crop=in_h*16/9,scale=320x180 15 3:22.917 3:27' | ||
${BASE}/encode-asset.sh "${SOURCEDIR}/cosmos_laundromat_2k.mp4" "${BASE}/../tests/fixtures/assets/cosmosregret-320x134par-15fps-5.3s.mp4" scale=320x180:force_original_aspect_ratio=decrease 15 4:29.417 4:34.708 | ||
fi | ||
|
||
if [ -f "${SOURCEDIR}/bbb_sunflower_1080p_30fps_normal.mp4" ]; then | ||
${BASE}/encode-asset.sh "${SOURCEDIR}/bbb_sunflower_1080p_30fps_normal.mp4" "${BASE}/../tests/fixtures/assets/bbbjumprope-320x180-15fps-5.5s.mp4" scale=320x180 15 4:34.767 4:40.367 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters