ffmpeg xxxx > xxxx.log 2>&1

if ! grep "bad header" <xxxx.log
then
# エラー処理
fi