Introduction
Introduction Statistics Contact Development Disclaimer Help
ffmpeg-effect: handle input files without an audio track - annna - Annna the ni…
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 3f0d1a63bf72da4943bb830d8ca7d86c6b4a8586
parent c4bdefe72c60a62c55e32acaa0f240fe1f88633c
Author: Anders Damsgaard <[email protected]>
Date: Tue, 22 Jun 2021 22:08:15 +0200
ffmpeg-effect: handle input files without an audio track
when no audio track is present, add one from the overlay
Signed-off-by: Annna Robert-Houdin <[email protected]>
Diffstat:
M ffmpeg-effect | 45 +++++++++++++++++++++++------…
1 file changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/ffmpeg-effect b/ffmpeg-effect
@@ -15,20 +15,43 @@ usage() {
exit 1
}
-mix_audio() {
- $ffmpeg_common -i "$2" -i "$1" \
- -filter_complex "amerge=inputs=2" \
+has_audio() {
+ ffprobe "$1" 2>&1 | grep -qE 'Stream .* Audio: '
+}
+
+replace_audio() {
+ $ffmpeg_common -i "$1" -i "$2" \
+ -c:v copy -map 1:v:0 -map 0:a:0 -shortest \
"$3" </dev/null
}
+mix_audio() {
+ if has_audio "$2"; then
+ $ffmpeg_common -i "$1" -i "$2" \
+ -filter_complex "amerge=inputs=2" \
+ "$3" </dev/null
+ else
+ replace_audio "$1" "$2" "$3"
+ fi
+}
+
mix_audio_video() {
- $ffmpeg_common -i "$2" \
- -i "$1" \
- -filter_complex "
- [0:v] scale=w=${4:-1920}:h=${5:-1080}, pad=w=${4:-1920…
- [video0][1:v] blend=all_mode=average:shortest=1;
- amix=inputs=2:duration=shortest:weights=3 2" \
- "$3" </dev/null
+ if has_audio "$2"; then
+ $ffmpeg_common -i "$2" \
+ -i "$1" \
+ -filter_complex "
+ [0:v] scale=w=${4:-1920}:h=${5:-1080}, pad=w=$…
+ [video0][1:v] blend=all_mode=average:shortest=…
+ amix=inputs=2:duration=shortest:weights=3 2" \
+ "$3" </dev/null
+ else
+ $ffmpeg_common -i "$2" \
+ -i "$1" \
+ -filter_complex "
+ [0:v] scale=w=${4:-1920}:h=${5:-1080}, pad=w=$…
+ [video0][1:v] blend=all_mode=average:shortest=…
+ "$3" </dev/null
+ fi
}
process_filter() {
@@ -70,7 +93,7 @@ process_filter() {
sexify)
mix_audio "${mediadir}/careless_whisper.mp3" "$2" "$3"…
doomify)
- mix_audio "$2" "${mediadir}/doom.mp3" "$3";;
+ mix_audio "${mediadir}/doom.mp3" "$2" "$3";;
scrollify)
mix_audio "${mediadir}/elder_scrolls.mp3" "$2" "$3";;
sendtohell|amsterdamify)
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.