#!/bin/bash
ip_addresses=(
  192.168.20.43
  192.168.20.44
)
for i in "${!ip_addresses[@]}"; do
  ip="${ip_addresses[$i]}"
  output_filename="./videos/ipcam/camera_${i}_stream.m3u8"
  ffmpeg -i "rtsp://dev:rezaIpCctv1402@${ip}:554/cam/realmonitor?channel=${i}&subtype=1" -fflags flush_packets -max_delay 5 -flags -global_header -hls_time 5 -hls_list_size 3 -vcodec copy -tag:v hvc1 -y "${output_filename}"
done