From f105776271af083d5b59da5603e8fa539b688fe9 Mon Sep 17 00:00:00 2001 From: home Date: Sun, 26 Nov 2023 01:23:30 +0300 Subject: [PATCH] ffmpeg : add mux cover. --- .README.md | 1 + .config/bash/module/ffmpeg.sh | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/.README.md b/.README.md index be2ed32..7d47dcb 100644 --- a/.README.md +++ b/.README.md @@ -485,6 +485,7 @@ Variable|Description Command|Description ---|--- `ffmpeg_mux_audio `|Mux external audio into one container with video (replaces original audio). Run inside dir with original video. names should be the same for each video. +`ffmpeg_mux_cover `|Mux image into files of specified format. ## File. diff --git a/.config/bash/module/ffmpeg.sh b/.config/bash/module/ffmpeg.sh index b5caf6c..85b0fa3 100644 --- a/.config/bash/module/ffmpeg.sh +++ b/.config/bash/module/ffmpeg.sh @@ -9,3 +9,21 @@ ffmpeg_mux_audio() for file in *; do ffmpeg -i "$file" -i "$1"/"$file" -c copy -map 0:v:0 -map 1:a:0 -shortest "$2"/"$file"; done } + +# Mux cover into music file. +# Usage: ffmpeg_mux_cover +ffmpeg_mux_cover() +{ + if [[ "${1}" = "" ]]; then + echo "Usage: ffmpeg_mux_cover " + return + fi + + mkdir out + + for file in *.${1}; do + ffmpeg -i "${file}" -i "${2}" -map 0:a -map 1 -codec copy -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" -disposition:v attached_pic ./out/"${file}" || return 1 + done + + mv out/* . && rm -d out/ && rm "${2}" +}