仅延迟 mp4 文件中音频流的一个通道
如何仅对包含立体声音频流的 mp4 的 1 个音频通道应用延迟?
我有一个包含 2 个流的视频 test.mp4
:
Stream #0:0[0x1](und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 8042 kb/s, 60 fps, 60 tbr, 60k tbn (default)
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 126 kb/s (default)
如您所见AAC 音轨是立体声的。我需要将 2 秒延迟应用于音频流(流 1)中的右通道。
下面是一个脚本,可以成功地对两个音频流执行此操作(此处有详细说明):
ffmpeg -i "test.mp4" -itsoffset 2 -i "test.mp4" -map 0:v -map 1:a -c:v copy "test_delay.mp4"
基本上它使用 -map
选项来获取输入 id 0
的 v
视频流(-i "test.mp4"是第一个, id
0
的未延迟输入),以及输入 id 1
的 a
音频流(-itsoffset 2 -i "test. mp4"
是第二个 2 秒延迟的输入,id 为 1
),用于构成最终输出。
我想我应该尝试使用 -map_channel
,但我也很困惑如何将其与 -itsoffset
选项合并。
以下结果导致视频没有音频流:
ffmpeg -i "test.mp4" -itsoffset 2 -i "test.mp4" -map 0:v -map_channel 1.1.0:0.0 -map_channel 1.1.1:0.1 -c:v copy "test_delay.mp4"
而以下结果(这次包括 -map 1:a
)导致 R ch 成功延迟,但根本没有 L ch(单声道音频流) ):
ffmpeg -i "test.mp4" -itsoffset 2 -i "test.mp4" -map 0:v -map 1:a -map_channel 1.1.0:0.0 -map_channel 1.1.1:0.1 -c:v copy "test_delay.mp4"
有什么建议吗?
该命令将由自动化且不受监控的系统运行,因此如果可能的话,我真的尽力将其限制为仅执行 1 个命令。
How can I apply a delay to only 1 audio channel of an mp4 containing a stereo audio stream?
I have a video test.mp4
with 2 streams:
Stream #0:0[0x1](und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 8042 kb/s, 60 fps, 60 tbr, 60k tbn (default)
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 126 kb/s (default)
As you can see the AAC track is stereo. I need to apply a 2-second delay to just the right channel in the audio stream (stream 1).
Here is a script that successfully does this for both audio streams (detailed description here):
ffmpeg -i "test.mp4" -itsoffset 2 -i "test.mp4" -map 0:v -map 1:a -c:v copy "test_delay.mp4"
Basically it's using the -map
option to grab input id 0
's v
video stream (-i "test.mp4"
is the first, undelayed input with id 0
), along with input id 1
's a
audio stream (-itsoffset 2 -i "test.mp4"
is the second, 2-sec-delayed input with id 1
) to compose the final output.
I think I should be trying to use -map_channel
instead, but am confused how to incorporate it with the -itsoffset
option as well.
The following results in a video with no audio streams:
ffmpeg -i "test.mp4" -itsoffset 2 -i "test.mp4" -map 0:v -map_channel 1.1.0:0.0 -map_channel 1.1.1:0.1 -c:v copy "test_delay.mp4"
And the following (including -map 1:a
this time) results in R ch being delayed successfully, but with no L ch at all (mono audio stream):
ffmpeg -i "test.mp4" -itsoffset 2 -i "test.mp4" -map 0:v -map 1:a -map_channel 1.1.0:0.0 -map_channel 1.1.1:0.1 -c:v copy "test_delay.mp4"
Any tips?
This command is to be run by an automated and unmonitored system so I'm really trying to keep it limited to just 1 command execution, if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
adelay
过滤器:adelay< /code> 采用以毫秒为单位的延迟序列,以
|
分隔,立体声通道布局为LEFT|RIGHT
,因此将第二个延迟设置为 2000 毫秒。Use
adelay
filter:adelay
takes a sequence of delays in milliseconds, separated by|
, and stereo channel layout isLEFT|RIGHT
so set the 2nd delay to be 2000 ms.及时移动而不是延迟,请参阅此命令,该命令使用过滤器在
test.mp4
中将正确的音频流通道偏移 2 秒:@kesh 的答案是正确的,但如果单个音频通道必须 已知
test.mp4
的持续时间短于 99 秒adelay=2000|0
将 LEFT 通道延迟 2000 毫秒,以抵消在跟随过滤器;最终左声道将返回到原来的位置@kesh's answer is correct but if a single audio channel must be moved earlier in time instead of delayed, see this command which uses filters to offset the right audio stream channel by 2 seconds in
test.mp4
:Note that
test.mp4
is known to be shorter than 99 seconds in durationadelay=2000|0
is delaying the LEFT channel by 2000 millis in order to offset what will happen in the following filters; ultimately the left channel will be returned to its original position