0

I have a system setup to record videos from multipul ip cameras into mp4 files at the end of everyday a new folder is created and the next days worth of cam footage is saved in here and so on day after day.

I am trying to convert each of these mp4 files into segmented hls streams i can convert a single file with no problems using the following code

ffmpeg -i cam10029.mp4 -threads 0 -vf scale=1280:-2:force_original_aspect_ratio=decrease -c:a aac -ar 48000 -b:a 128k -c:v h264 -profile:v main -crf 20 -g 48 -keyint_min 48 -sc_threshold 0 -b:v 1500k -maxrate 2675k -bufsize 3750k -hls_time 6 -hls_playlist_type vod -hls_segment_filename index_%03d.ts index.m3u8

but each folder can have sometimes 100-200 videos in it and doing this one by one takes for ever changing the name and rerunning the command and having to check when done

i tried using something like this

for i in *.mp4;
  do name=`echo "$i" | cut -d'.' -f1`
  echo "$name"
  ffmpeg -i "$i" "${name}.mov"
done

sadly this did not work on windows in a batch file it just flickered on screen then gone.

I am now using ubuntu 18 and wondering if there is a way todo it better on here ?

what i would like to do is run say one convert.sh file and have it find all the videos in the folder then create a new folder for the first video with the same name as the video then convert it into segmented stream and save the .ts and .m3u8 files in this folder delete the origenal video file then move onto the next file and do the same until all the files are converted in the folder so i can then link to the m3u8 files for each camera via my android app

Dude2019
  • 75
  • 7
  • Does your Windows version support bash scripts? If not that you'll have to use a batch file. In Ubuntu you can use `find`. See this [simplified example](https://stackoverflow.com/a/41105794/). – llogan Feb 10 '20 at 20:07
  • i have all ready tried a batch file as stated above but it fails to work i will have a look at the link you provided – Dude2019 Feb 11 '20 at 13:56
  • What I meant was you can't dump that code into a `.bat` file because it isn't Batch language. It is Bash. – llogan Feb 11 '20 at 19:03
  • yeh i have found a way todo it and all working good now i will update my answer later – Dude2019 Feb 15 '20 at 23:11

0 Answers0