ffmpeg 流偏移命令 (-itsoffset) 不起作用 [英] ffmpeg stream offset command (-itsoffset) not working

查看:113
本文介绍了ffmpeg 流偏移命令 (-itsoffset) 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有人能就 ffmpeg 使用 itsoffset 提出一些建议,我将不胜感激.我已经阅读了许多关于这个主题的帖子,其中一些非常清楚地解释了如何使用 -itsoffset 重新同步音频和视频,但我一直无法使其正常工作.我的 avi 文件是用 ffmpeg 编码的,分两遍,第二遍使用以下命令:

I would really appreciate if someone could give some pointers regarding the use of itsoffset with ffmpeg. I have read a number of posts on this subject, some of them explain very clearly how to re-synchronize audio and video with -itsoffset, but I haven't been able to make it work. My avi file is encoded with ffmpeg, in two passes, using the following command for the second pass:

ffmpeg -i whole-vts_01.avs -pass 2 -y -vcodec libxvid -vtag XVID -b:v 1300K -g 240 -trellis 2 -mbd rd -flags +mv4+aic -acodec ac3 -ac 2 -ar 48000 -b:a 128k output.avi

无论出于何种原因,我最终都会在视频中延迟 1 秒(或音频提前 1 秒).它不会经常发生,但我不时看到它.在其他尝试中,我尝试了以下方法:

For whatever reason, I end up with a 1 sec delay in the video (or the audio is 1 sec early). It doesn't happen too often but I see it from time to time. Among other attempts, I have tried the following:

(1) ffmpeg -i output.avi -itsoffset 00:00:01.0 -i output.avi -vcodec copy -acodec copy -map 0:0 -map 1:1 output-resynched.avi
(2) ffmpeg -i output.avi -itsoffset 00:00:01.0 -i output.ac3 -vcodec copy -acodec copy -map 0:0 -map 1:0 output-resynched2.avi
(3) ffmpeg -itsoffset -00:00:01.00 -i output.avi output-resynched8.avi
(4) ffmpeg -i output.avi -itsoffset -1.0 -i output.avi -vcodec copy -acodec copy -map 0:1 -map 1:0 output-resynched13.avi

结果如下:

  1. 音频出现乱码,只有 5m 35 s 长,而 1h 41m 长.
  2. (Output.ac3是output.avi的音频组件)视频和音频与原始相同,偏移不起作用
  3. 音频确实发生了变化,但原始编码参数替换为默认参数(如预期).
  4. 音频出现乱码,只有 9m 56s 长,而 1h 41m 长.

我看到很多人都在解释,并且显然使用了上面描述的过程,但它似乎对我不起作用.我错过了一些明显的东西吗?我非常希望能够使用 -itsoffset,因为它比我的解决方案更干净.

I see that many people explain, and apparently use the process described above, but it doesn't seem to be working for me. Am I missing something obvious? I would very much like to be able to use -itsoffset as it is cleaner than my workaround solution.

FWIW,这是获得所需结果的另一种更长的方法:

FWIW, here is a different, and longer way of obtaining the desired result:

首先使用 -ss 创建一个仅移动的视频文件:

First create a shifted video only file using -ss:

ffmpeg -i output.avi -ss 1.0 -vcodec copy -an oupput_videoshifted.avi

然后提取音频:

ffmpeg -i output.avi -vn -acodec copy outputaudioonly.ac3

最后重新混合两个组件:

And finally remux both components:

ffmpeg -i output_videoshifted.avi -i output_audioonly.ac3 -vcodec copy -acodec copy -map 0:0 -map 1:0 output-resynched14.avi

该过程有效,速度足够快,但我真的更喜欢使用 one pass -itsoffset 解决方案.

The process works, is fast enough, but I would really prefer to use the one pass -itsoffset solution.

推荐答案

这是我所做的并且对我有用

Here is what I did and it work for me

第一个输入设置 -i 和第二个输入来自同一个视频文件.

The first input setting -i and the second input is come from the same one video file.

第一个输入视频延迟 1 秒,第二个输入音频只需复制

Delay 1 second in first input video and the second input audio just make a copy

ffmpeg -y -itsoffset 00:00:01.000 -i "d:Video1.mp4" -i "d:Video1.mp4"
 -map 0:v -map 1:a -vcodec copy -acodec copy
 -f mp4 -threads 2 -v warning "Video2.mp4"

第二个输入音频延迟 1 秒,第一个输入视频只需复制

Delay 1 second in second input audio and the first input video just make a copy

ffmpeg -y -i "d:Video1.mp4" -itsoffset 00:00:01.000 -i "d:Video1.mp4"
 -map 0:v -map 1:a -vcodec copy -acodec copy
 -f mp4 -threads 2 -v warning "Video2.mp4"

这篇关于ffmpeg 流偏移命令 (-itsoffset) 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆