bash variable changes in loop with ffmpeg

前端 未结 1 678
挽巷
挽巷 2020-12-21 00:57

I wrote a skript to quickly create short preview clips from vides I recorded on timestamps that I found worth checking out later for cutting. My file with the timestamps is

相关标签:
1条回答
  • 2020-12-21 01:30

    ffmpeg reads from standard input, consuming data from $1 that was intended for the read command at the top of the loop. Redirect its standard input from /dev/null:

    while IFS="#" read file timestamps; do
      filename="$file.MP4"
      for time in $timestamps; do
        ffmpeg -ss 00:${time}.0 -i "orig/${filename}" \
               -c copy -t 10 "preview/${file}_${time}.MP4" < /dev/null
      done
    done < "$1"
    

    echo does not read from standard input, which is why your modification made it appear to be working correctly.

    0 讨论(0)
提交回复
热议问题