ffmpeg 流偏移命令(-itsoffset)不起作用 [英] ffmpeg stream offset command (-itsoffset) not working
问题描述
如果有人能提供一些关于在 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
结果如下:
- 音频出现乱码,长度仅为 5 米 35 秒,而 1 小时 41 米.
- (Output.ac3 是 output.avi 的音频组件) 视频和音频与原版相同,偏移不起作用
- 音频确实发生了变化,但原始编码参数已替换为默认参数(如预期的那样).
- 音频出现乱码,只有 9 米 56 秒,而 1 小时 41 米.
我看到很多人解释,并且显然使用了上述过程,但它似乎对我不起作用.我错过了一些明显的东西吗?我非常希望能够使用 -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
最后再混合两个组件:
ffmpeg -i output_videoshifted.avi -i output_audioonly.ac3 -vcodec copy -acodec copy -map 0:0 -map 1:0 output-resynched14.avi
该过程有效,速度足够快,但我更喜欢使用一次性 -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屋!