mirror of
https://github.com/familyfriendlymikey/mpv-cut
synced 2024-07-01 12:08:58 +00:00
utils tweaks
This commit is contained in:
parent
26e9907ff3
commit
3b18f1161f
19
utils
19
utils
@ -11,26 +11,39 @@ mcc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
concat() {
|
concat() {
|
||||||
|
if [[ $# -eq 0 ]]; then
|
||||||
|
echo "You must provide a prefix"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
local prefix="$1"
|
local prefix="$1"
|
||||||
shift
|
shift
|
||||||
ffmpeg -f concat -safe 0 -i <(printf 'file %q\n' "$PWD"/"$prefix"*) "$@"
|
ffmpeg -y -f concat -safe 0 -i <(printf 'file %q\n' "$PWD"/"$prefix"*) "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
make_cuts() {
|
make_cuts() {
|
||||||
|
if [[ $1 != *".list" ]]; then
|
||||||
|
echo "You must supply a single .list file as argument"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
local list="$1"
|
local list="$1"
|
||||||
local vid="${list%.*}"
|
local vid="${list%.*}"
|
||||||
local ext="${vid##*.}"
|
local ext="${vid##*.}"
|
||||||
local vid_noext="${vid%.*}"
|
local vid_noext="${vid%.*}"
|
||||||
local start_ts_hms
|
local start_ts_hms
|
||||||
local end_ts_hms
|
local end_ts_hms
|
||||||
|
local ffmpeg_cmd=("ffmpeg" "-y" "-i" "$vid")
|
||||||
shift
|
shift
|
||||||
|
|
||||||
while IFS=: read -r channel_name start_ts end_ts || [[ -n "$channel_name" ]]; do
|
while IFS=: read -r channel_name start_ts end_ts || [[ -n "$channel_name" ]]; do
|
||||||
if [[ -z "$end_ts" ]]; then continue; fi
|
if [[ -z "$end_ts" ]]; then continue; fi
|
||||||
start_ts_hms="$(_mpv_cut_to_hms "$start_ts")"
|
start_ts_hms="$(_mpv_cut_to_hms "$start_ts")"
|
||||||
end_ts_hms="$(_mpv_cut_to_hms "$end_ts")"
|
end_ts_hms="$(_mpv_cut_to_hms "$end_ts")"
|
||||||
echo "$channel_name" "$start_ts" "$end_ts"
|
ffmpeg_cmd+=("-ss" "$start_ts" "-to" "$end_ts" "$@" "CUT_${channel_name}_${vid_noext}_${start_ts_hms}_${end_ts_hms}.${ext}")
|
||||||
ffmpeg -nostdin -ss "$start_ts" -to "$end_ts" -i "$vid" "$@" "CUT_${channel_name}_${vid_noext}_${start_ts_hms}_${end_ts_hms}.${ext}"
|
|
||||||
done < "$list"
|
done < "$list"
|
||||||
|
|
||||||
|
"${ffmpeg_cmd[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_mpv_cut_to_hms() {
|
_mpv_cut_to_hms() {
|
||||||
|
Loading…
Reference in New Issue
Block a user