0

I'm doing a car live stream video system. I try to convert the video from .avi to .mp4.

So I use inotify-tools to detect if a new file updated. Then I encounter a problem. When 4 video update at a same time. Ffmpeg only convert one video. It doesn't convert others video when the first was converted.

There is the bash code below:

#!/bin/bash
TARGET=/home/test/update
PROCESSED=/home/test/convert

inotifywait -m -e create -e moved_to --format "%f" $TARGET \
    | while read FILENAME
            do
                    ddate=${FILENAME:0:8}
                    dtime=${FILENAME:8:6}
                    camera=${FILENAME:77:1}
                    echo Detected $FILENAME, moving and compressing...
                    nFILENAME="KLE-5592_"${ddate}"_"${dtime}"_CH"${camera}"$
                    ffmpeg -i $TARGET/$FILENAME -vcodec libx264 -crf 40 $PROCESSED/$nFILENAME 
            done

Thanks for help!

Xyanophat
  • 11
  • 4

0 Answers0