I have many video files that are split by Day, Camera Channel, Event time range (YYYY-MM-DD/VIDEOCHANNELNUMBER-EVENTIMERANGE.mp4
)
/2021-07-03/ch2_main_20210703074010_20210703074154.mp4
/2021-07-03/ch2_main_20210703074156_20210703074357.mp4
/2021-07-03/ch2_main_20210703074446_20210703074537.mp4
/2021-07-03/ch2_main_20210703074618_20210703075119.mp4
/2021-07-03/ch2_main_20210703075153_20210703075312.mp4
/2021-07-03/ch2_main_20210703075337_20210703080422.mp4
I want to merge these clips by Day and Camera Channel only (ie /2021-04-03-CH1.mp4
)
My process is:
- Iterate through each date folder (
for VIDEODIR in */
) - Within each folder, iterate through each channel number (
for VIDEOCHANNELNUMBER in 1 2 3 4 5 6; do
) - for each channel number, find all the video files to combine (
for f in $VIDEODIR/ch$VIDEOCHANNELNUMBER*.mp4 ; do
) - FFMPEG combine and save this file into the root directory (
ffmpeg -i $VIDEOLIST -c copy "$DATE-CH$VIDEOCHANNELNUMBER.mp4"
) - When successful delete the directory of all the original clips. (
if [ $? -eq 0 ]; then rm $VIDEODIR -r fi
)
I'm stuck because Step 2 errors out when there are no matches due to that video channel being offline during that day for some reason. (zsh: no matches found: /2021-07-03/ch1*.mp4
). This breaks the entire loop, rather than skip and continue.