ffmpeg/draft
This commit is contained in:
parent
3e0459b85c
commit
006abeb31c
1 changed files with 88 additions and 0 deletions
88
sh/ffmpeg.sh
88
sh/ffmpeg.sh
|
@ -21,3 +21,91 @@ rwx_ffmpeg_device_formats() {
|
|||
-list_formats "all" \
|
||||
-i "${device}"
|
||||
}
|
||||
|
||||
# ╭────────┬───────╮
|
||||
# │ ffmpeg │ input │
|
||||
# ╰────────┴───────╯
|
||||
|
||||
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_nearstream_ccd10() {
|
||||
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_fast() {
|
||||
local file="${1}"
|
||||
[ -n "${file}" ] || return
|
||||
set -- \
|
||||
-codec:v "libx264" \
|
||||
-preset "ultrafast" \
|
||||
-crf "0" \
|
||||
-y "${file}"
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
rwx_ffmpeg_output_slow() {
|
||||
local file="${1}"
|
||||
local crf="${2}"
|
||||
local codec="${3}"
|
||||
[ -n "${file}" ] || return
|
||||
[ -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" \
|
||||
-y "${file}"
|
||||
local argument
|
||||
for argument in "${@}"; do echo "${argument}"; done
|
||||
}
|
||||
|
||||
# ╭────────┬────────╮
|
||||
# │ ffmpeg │ record │
|
||||
# ╰────────┴────────╯
|
||||
|
||||
rwx_ffmpeg_record_ccd10() {
|
||||
local file="${1}"
|
||||
[ -n "${file}" ] || return
|
||||
set -- \
|
||||
$(rwx_ffmpeg_input_nearstream_ccd10) \
|
||||
$(rwx_ffmpeg_output_fast "${file}")
|
||||
local argument
|
||||
echo "${@}"
|
||||
ffmpeg "${@}"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue