Bash script does not continue to read the next line of file

前端 未结 5 613
南笙
南笙 2021-02-06 17:27

I have a shell script that saves the output of a command that is executed to a CSV file. It reads the command it has to execute from a shell script which is in this format:

5条回答
  •  没有蜡笔的小新
    2021-02-06 18:06

    I just had the same problem.

    I believe ffmpeg is responsible for this behaviour.

    My solution for this problem:

    1) Call ffmpeg with an "&" at the end of your ffmpeg command line

    2) Since now the skript will not wait till completion of the ffmpeg process, we have to prevent our script from starting several ffmpeg processes. We achieve this goal by delaying the loop pass while there is at least one running ffmpeg process.

    #!/bin/bash
    
    cat FileList.txt |
    while read VideoFile; do
         &
        FFMPEGStillRunning="true"
        while [ "$FFMPEGStillRunning" = "true" ]; do
            Process=$(ps -C ffmpeg | grep -o -e "ffmpeg" )
            if [ -n "$Process" ]; then
                FFMPEGStillRunning="true"
            else
                FFMPEGStillRunning="false"
            fi 
            sleep 2s
        done
    done
    

提交回复
热议问题