Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash FFmpeg脚本跳过文件_Bash_Shell_Ffmpeg - Fatal编程技术网

Bash FFmpeg脚本跳过文件

Bash FFmpeg脚本跳过文件,bash,shell,ffmpeg,Bash,Shell,Ffmpeg,我编写了一个shell脚本来转换许多视频文件,并在文件名后面附加一些内容来保存它们。该脚本可以工作,但它似乎随机跳过文件,而且很多文件都是这样 当我重新运行脚本时,它将转换以前跳过的文件。如何让它停止跳过文件 workingDir=/home/user/Videos # get list of files to convert find /video/folder -iname "*.mp4" > $workingDir/file_list # convert files cat $w

我编写了一个shell脚本来转换许多视频文件,并在文件名后面附加一些内容来保存它们。该脚本可以工作,但它似乎随机跳过文件,而且很多文件都是这样

当我重新运行脚本时,它将转换以前跳过的文件。如何让它停止跳过文件

workingDir=/home/user/Videos

# get list of files to convert
find /video/folder -iname "*.mp4" > $workingDir/file_list

# convert files
cat $workingDir/file_list | while read LINE; do
    # FFmpeg often cuts off the beginning of this line
    echo "$(dirname "$LINE")/$(basename "$LINE")"
    if /usr/bin/ffmpeg -n -loglevel panic -v quiet -stats -i "$LINE" \
        -c:v libx264 -vf scale="trunc(oh*a/2)*2:320" \
        -pix_fmt yuv420p -preset:v slow -profile:v main -tune:v animation -crf 23 \
        "$(dirname "$LINE")/$(basename "$LINE" \.mp4)"_reencoded.mp4 2>/dev/null; then
            echo "Success: $(dirname "$LINE")/$(basename "$LINE")" >> $workingDir/results
    else
        echo "Failed:  $(dirname "$LINE")/$(basename "$LINE")" >> $workingDir/results
    fi
done

一个问题似乎是FFmpeg干扰了脚本。FFmpeg输出通常会切断下一个命令的开头,即使输出未显示。这可以通过if语句之前的回显行来证明,它经常被切断。但是,即使对于没有被截断的行,它们中的大多数也会被无缘无故地跳过。

ffmpeg
从stdin读取,从而在读取时使用
的输入。只需添加