# ╭────────┬─────────┬───────╮ # │ 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_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 "${@}" }