在 Bash 的迴圈裡面跑 FFmpeg

Bash 的迴圈裡面跑 FFmpeg 有時候會遇到奇怪的靈異現象,發現是這個問題:「execute ffmpeg command in a loop」。

原因是當你用 while + read 產生迴圈時會有對 stdin 的操作行為,而 FFmpeg 預設也會去讀 stdin (WTF),於是兩邊就打架了。

解法是用 -nostdin 叫 FFmpeg 不要手賤去讀 stdin,這樣就可以解決這個問題。

One thought on “在 Bash 的迴圈裡面跑 FFmpeg”

  1. kcwu says:

    我踩過不太一樣, 但類似概念的問題
    $ cat foo.sh | bash
    foo.sh 的內容其中一行是 ssh
    然後 foo.sh ssh 後面的指令就被 ssh 吞掉了
    https://superuser.com/questions/1194343/

Leave a Reply

Your email address will not be published. Required fields are marked *