This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/ffmpeg.sh

51 lines
1.3 KiB
Bash
Raw Normal View History

2023-10-30 03:49:10 +03:00
# mux audio into containers. file names in sound and current dirrectories must match. tmp usage for anime downloads.
# usage: ffmpeg_mux_audio <SOUND> <OUTPUT DIR>
2023-08-08 16:24:15 +03:00
ffmpeg_mux_audio()
{
if [[ "$1" = "" ]]; then
2023-10-30 03:49:10 +03:00
echo "usage: ffmpeg_mux_audio <SOUND> <OUTPUT DIR>"
2023-08-08 16:24:15 +03:00
return
fi
for file in *; do ffmpeg -i "$file" -i "$1"/"$file" -c copy -map 0:v:0 -map 1:a:0 -shortest "$2"/"$file"; done
}
2023-11-26 01:23:30 +03:00
# Mux cover into music file.
# Usage: ffmpeg_mux_cover <FORMAT> <COVER>
ffmpeg_mux_cover()
{
if [[ "${1}" = "" ]]; then
echo "Usage: ffmpeg_mux_cover <FORMAT> <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}"
}
_ffprobe_fps()
{
local fps=$(ffprobe -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate "${1}")
fps="${fps%%/*}"
echo "${fps}"
}
_ffprobe_keyint()
{
local fps=$(_ffprobe_fps "${1}")
echo $((fps*5))
}
_ffprobe_ba()
{
local ba=$(ffprobe -v error -select_streams a:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 "${1}")
echo $((ba/1024))
}
export -f _ffprobe_keyint _ffprobe_ba _ffprobe_fps