mirror of
https://github.com/familyfriendlymikey/mpv-cut
synced 2024-07-01 12:08:58 +00:00
fix make_cuts not reading last line, make_cuts output filename should
facilitate concatenation in order of timestamps
This commit is contained in:
parent
816a5d5962
commit
e1156f8c57
16
utils
16
utils
@ -12,8 +12,20 @@ make_cuts() {
|
|||||||
local ext="${vid##*.}"
|
local ext="${vid##*.}"
|
||||||
local vid_noext="${vid%.*}"
|
local vid_noext="${vid%.*}"
|
||||||
shift
|
shift
|
||||||
while IFS=: read -r channel_name start_ts end_ts; 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
|
||||||
ffmpeg -nostdin -ss "$start_ts" -to "$end_ts" -i "$vid" "$@" "CUT_${channel_name}_${vid}_${start_ts}_${end_ts}.${ext}"
|
local start_ts_hms="$(_mpv_cut_to_hms "$start_ts")"
|
||||||
|
local end_ts_hms="$(_mpv_cut_to_hms "$end_ts")"
|
||||||
|
echo $channel_name $start_ts $end_ts
|
||||||
|
ffmpeg -nostdin -ss "$start_ts" -to "$end_ts" -i "$vid" "$@" "CUT_${channel_name}_${vid}_${start_ts_hms}_${end_ts_hms}.${ext}"
|
||||||
done < "$list"
|
done < "$list"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_mpv_cut_to_hms() {
|
||||||
|
local total_seconds="$1"
|
||||||
|
local hours=$(( ${total_seconds%.*} / 3600 ))
|
||||||
|
local minutes=$(( (${total_seconds%.*} % 3600) / 60 ))
|
||||||
|
local seconds=$(( ${total_seconds%.*} % 60 ))
|
||||||
|
local milliseconds=$(printf "%.0f" $(echo "($total_seconds - ${total_seconds%.*}) * 1000" | bc))
|
||||||
|
printf "%02d-%02d-%02d-%03d\n" $hours $minutes $seconds $milliseconds
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user