You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu下执行FFmpeg视频分割命令报bash语法错误求助

Fixing the Bash Syntax Error in Your FFmpeg Command

Hey there, I spot the issue immediately—your FFmpeg command runs smoothly on Windows but breaks in Ubuntu's bash due to how bash handles special characters like parentheses. Let's break this down and get it fixed.

The Root Cause

Windows CMD treats parentheses () as plain, regular characters. But bash interprets them as special syntax for things like subshells or command groups. In your -force_key_frames parameter, the expr:gte(t,n_forced*0.0333333333333333) part has unescaped parentheses, which confuses bash and triggers that syntax error.

Two Simple Fixes

You can use either of these approaches to make the command work in Ubuntu:

1. Wrap the -force_key_frames parameter in single quotes

This tells bash to treat the entire string as a literal, ignoring any special characters inside:

ffmpeg -i "data/raw_data/000000005.avi" -vf fps=X -f segment -segment_time 0.0333333333333333 -force_key_frames 'expr:gte(t,n_forced*0.0333333333333333)' -reset_timestamps 1 -segment_time_delta 1.0 -c:a copy "test_break_up/audios/%d.wav"

2. Escape the parentheses with backslashes

Add a backslash \ before each ( and ) to tell bash they're regular characters, not special syntax:

ffmpeg -i "data/raw_data/000000005.avi" -vf fps=X -f segment -segment_time 0.0333333333333333 -force_key_frames expr:gte\(t,n_forced*0.0333333333333333\) -reset_timestamps 1 -segment_time_delta 1.0 -c:a copy "test_break_up/audios/%d.wav"

Recommendation

The single quote method is cleaner and less error-prone, especially if your keyframe expression gets more complex later. Bash won't parse anything inside single quotes as special syntax, so your expression stays exactly as you intended.

内容的提问来源于stack exchange,提问作者jameshwart lopez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:46:49