refactor(history): commit development branch
All checks were successful
/ job (push) Successful in 1m12s
All checks were successful
/ job (push) Successful in 1m12s
new development branch from root commit
This commit is contained in:
parent
3e562930f6
commit
020aaa0b9a
94 changed files with 4804 additions and 0 deletions
194
sh/ffmpeg.sh
Normal file
194
sh/ffmpeg.sh
Normal file
|
@ -0,0 +1,194 @@
|
|||
# ╭────────┬─────────┬───────╮
|
||||
# │ ffmpeg │ devices │ reset │
|
||||
# ╰────────┴─────────┴───────╯
|
||||
|
||||
_rwx_cmd_rwx_ffmpeg_devices_reset() { rwx_ffmpeg_devices_reset "${@}"; }
|
||||
rwx_ffmpeg_devices_reset() {
|
||||
local module="uvcvideo"
|
||||
modprobe --remove "${module}" &&
|
||||
modprobe "${module}"
|
||||
}
|
||||
|
||||
# ╭────────┬────────┬─────────╮
|
||||
# │ ffmpeg │ device │ formats │
|
||||
# ╰────────┴────────┴─────────╯
|
||||
|
||||
rwx_ffmpeg_device_formats() {
|
||||
local device="${1}"
|
||||
[ -n "${device}" ] || device="/dev/video0"
|
||||
ffmpeg \
|
||||
-f "v4l2" \
|
||||
-list_formats "all" \
|
||||
-i "${device}"
|
||||
}
|
||||
|
||||
# ╭────────┬───────╮
|
||||
# │ ffmpeg │ input │
|
||||
# ╰────────┴───────╯
|
||||
|
||||
rwx_ffmpeg_input_blue_yeti() {
|
||||
local device="alsa_input.\
|
||||
usb-Generic_Blue_Microphones_2051BAB04XY8-00.analog-stereo"
|
||||
set -- \
|
||||
-f "pulse" \
|
||||
-i "${device}" \
|
||||
-ac "2" \
|
||||
-ar "48000"
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
rwx_ffmpeg_input_dell_precision() {
|
||||
local device="alsa_input.\
|
||||
pci-0000_00_1f.3.analog-stereo"
|
||||
set -- \
|
||||
-f "pulse" \
|
||||
-i "${device}" \
|
||||
-ac "2" \
|
||||
-ar "48000"
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
rwx_ffmpeg_input_file() {
|
||||
local file="${1}"
|
||||
local from="${2}"
|
||||
local to="${3}"
|
||||
[ -n "${file}" ] || return
|
||||
set -- \
|
||||
-i "${file}"
|
||||
if [ -n "${to}" ]; then
|
||||
set -- "${@}" \
|
||||
-ss "${from}" \
|
||||
-to "${to}"
|
||||
fi
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
rwx_ffmpeg_input_hdmi() {
|
||||
local device="${1}"
|
||||
[ -n "${device}" ] || device="/dev/video0"
|
||||
set -- \
|
||||
-f "v4l2" \
|
||||
-video_size "1920x1080" \
|
||||
-framerate "60" \
|
||||
-input_format "yuyv422" \
|
||||
-i "${device}"
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
# ╭────────┬────────╮
|
||||
# │ ffmpeg │ output │
|
||||
# ╰────────┴────────╯
|
||||
|
||||
rwx_ffmpeg_output_audio_fast() {
|
||||
set -- \
|
||||
-codec:a "flac" \
|
||||
-compression_level "0"
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
rwx_ffmpeg_output_audio_slow() {
|
||||
set -- \
|
||||
-codec:a "libopus" \
|
||||
-b:a "128k"
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
rwx_ffmpeg_output_file() {
|
||||
local file="${1}"
|
||||
[ -n "${file}" ] || return
|
||||
set -- \
|
||||
-y "${file}"
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
rwx_ffmpeg_output_video_fast() {
|
||||
set -- \
|
||||
-codec:v "libx264" \
|
||||
-preset "ultrafast" \
|
||||
-crf "0"
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
rwx_ffmpeg_output_video_slow() {
|
||||
local crf="${1}"
|
||||
local codec="${2}"
|
||||
[ -n "${codec}" ] || codec="libx264"
|
||||
if [ -z "${crm}" ]; then
|
||||
case "${codec}" in
|
||||
"libx264") crf="23" ;;
|
||||
"libx265") crf="28" ;;
|
||||
*) ;;
|
||||
esac
|
||||
fi
|
||||
set -- \
|
||||
-codec:v "${codec}" \
|
||||
-preset "veryslow" \
|
||||
-crf "${crf}" \
|
||||
-movflags "+faststart" \
|
||||
-pix_fmt "yuv420p"
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
# ╭────────┬────────╮
|
||||
# │ ffmpeg │ record │
|
||||
# ╰────────┴────────╯
|
||||
|
||||
rwx_ffmpeg_record_hdmi_precision() {
|
||||
local file="${1}"
|
||||
[ -n "${file}" ] || return
|
||||
# LATER alternative
|
||||
# shellcheck disable=SC2046,SC2312
|
||||
set -- \
|
||||
$(rwx_ffmpeg_input_hdmi) \
|
||||
$(rwx_ffmpeg_input_dell_precision) \
|
||||
$(rwx_ffmpeg_output_video_fast) \
|
||||
$(rwx_ffmpeg_output_audio_fast) \
|
||||
$(rwx_ffmpeg_output_file "${file}")
|
||||
echo "${@}"
|
||||
ffmpeg "${@}"
|
||||
}
|
||||
|
||||
rwx_ffmpeg_record_hdmi_yeti() {
|
||||
local file="${1}"
|
||||
[ -n "${file}" ] || return
|
||||
# LATER alternative
|
||||
# shellcheck disable=SC2046,SC2312
|
||||
set -- \
|
||||
$(rwx_ffmpeg_input_hdmi) \
|
||||
$(rwx_ffmpeg_input_blue_yeti) \
|
||||
$(rwx_ffmpeg_output_video_fast) \
|
||||
$(rwx_ffmpeg_output_audio_fast) \
|
||||
$(rwx_ffmpeg_output_file "${file}")
|
||||
echo "${@}"
|
||||
ffmpeg "${@}"
|
||||
}
|
||||
|
||||
# ╭────────┬────────╮
|
||||
# │ ffmpeg │ reduce │
|
||||
# ╰────────┴────────╯
|
||||
|
||||
rwx_ffmpeg_reduce() {
|
||||
local input="${1}"
|
||||
local output="${2}"
|
||||
local from="${3}"
|
||||
local to="${4}"
|
||||
[ -n "${output}" ] || return
|
||||
# LATER alternative
|
||||
# shellcheck disable=SC2046,SC2312
|
||||
set -- \
|
||||
$(rwx_ffmpeg_input_file "${input}" "${from}" "${to}") \
|
||||
$(rwx_ffmpeg_output_video_slow) \
|
||||
$(rwx_ffmpeg_output_audio_slow) \
|
||||
$(rwx_ffmpeg_output_file "${output}")
|
||||
echo "${@}"
|
||||
ffmpeg "${@}"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue