Audio FFMPEG剪辑广告使音频不同步

Audio FFMPEG剪辑广告使音频不同步,audio,video,ffmpeg,h.264,Audio,Video,Ffmpeg,H.264,Ubuntu 14.04.1,加载了真正的ffmpeg(avconv版本也有同样的问题) 我正在尝试使用HDPVR将MythTV中创建的文件,剪切广告并将视频放入MP4容器中,以便与MythRoku一起使用 命令 ffmpeg-i$file-acodec copy-vcodec copy-f mp4 file.mp4 很好。更新数据库后,我可以在MythRoku或Plex中查看文件 然而,当我试图剪掉商业广告时,每当我剪掉超过0分时,音频就会失去同步1秒多一点(音频延迟)。Totem Video

Ubuntu 14.04.1,加载了真正的ffmpeg(avconv版本也有同样的问题)

我正在尝试使用HDPVR将MythTV中创建的文件,剪切广告并将视频放入MP4容器中,以便与MythRoku一起使用

命令

ffmpeg-i$file-acodec copy-vcodec copy-f mp4 file.mp4

很好。更新数据库后,我可以在MythRoku或Plex中查看文件

然而,当我试图剪掉商业广告时,每当我剪掉超过0分时,音频就会失去同步1秒多一点(音频延迟)。Totem Video player和VLC都可以很好地播放生成的视频,但我可以在开始时看到一个“故障”,因为他们正在同步音频,所以我知道音频同步的信息在文件的某个地方。Mystroku和Plex在播放文件时都不同步。MythTV前端播放机确实正确地播放了它,我可以听到它同步音频时的“挂接”声

在阅读了几个小时的帖子和设置后,我得出了以下结论:

如果我说:

ffmpeg-i$file-acodec copy-vcodec copy-f mp4-ss 0-t out.mp4

该文件很好,可以在本地和Mystroku/Plex中播放

但是,如果我提前启动任何数量-即使是1秒-音频是不同步的

ffmpeg-i$file-acodec copy-vcodec copy-f mp4-ss 1-t out.mp4

我曾经尝试过先将视频(作为mp4)和音频(作为ac3)分开,分别分开,然后作为最后一步将它们重新组合在一起,但我得到了相同的结果

信息在文件中-图腾、VLC和前端都可以找到它。如何让ffmpeg计算同步并写入文件,使其正确

原始文件:

mythtv@marvin:~$ mediainfo /var/lib/mythtv/recordings/2225_20140824001500.mpg
General
ID                                       : 0 (0x0)
Complete name                            :     /var/lib/mythtv/recordings/2225_20140824001500.mpg
Format                                   : MPEG-TS
File size                                : 4.03 GiB
Duration                                 : 1h 45mn
Overall bit rate mode                    : Variable
Overall bit rate                         : 5 491 Kbps

Video
ID                                       : 4113 (0x1011)
Menu ID                                  : 1 (0x1)
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L4.0
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Format settings, GOP                     : M=4, N=32
Codec ID                                 : 27
Duration                                 : 1h 45mn
Bit rate mode                            : Variable
Bit rate                                 : 4 831 Kbps
Maximum bit rate                         : 20.0 Mbps
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 59.940 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.087
Stream size                              : 3.55 GiB (88%)
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 4352 (0x1100)
Menu ID                                  : 1 (0x1)
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Mode extension                           : CM (complete main)
Format settings, Endianness              : Big
Codec ID                                 : 129
Duration                                 : 1h 45mn
Bit rate mode                            : Constant
Bit rate                                 : 384 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
Compression mode                         : Lossy
Delay relative to video                  : -6ms
Stream size                              : 289 MiB (7%)
从0剪切的文件:

mythtv@marvin:~$ mediainfo 2225_20140824001500_1.mp4
General
Complete name                            : 2225_20140824001500_1.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom
File size                                : 58.5 MiB
Duration                                 : 1mn 45s
Overall bit rate mode                    : Variable
Overall bit rate                         : 4 676 Kbps
Writing application                      : Lavf54.63.104

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L4.0
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Format settings, GOP                     : M=4, N=32
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1mn 45s
Bit rate mode                            : Variable
Bit rate                                 : 4 281 Kbps
Maximum bit rate                         : 20.0 Mbps
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 59.940 fps
Minimum frame rate                       : 59.920 fps
Maximum frame rate                       : 59.960 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.077
Stream size                              : 53.6 MiB (92%)
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Mode extension                           : CM (complete main)
Format settings, Endianness              : Big
Codec ID                                 : ac-3
Duration                                 : 1mn 45s
Bit rate mode                            : Constant
Bit rate                                 : 384 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
Compression mode                         : Lossy
Stream size                              : 4.81 MiB (8%)
音频同步问题从1秒开始剪切文件:

mythtv@marvin:~$ mediainfo 2225_20140824001500_2.mp4
General
Complete name                            : 2225_20140824001500_2.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom
File size                                : 68.0 MiB
Duration                                 : 2mn 0s
Overall bit rate mode                    : Variable
Overall bit rate                         : 4 750 Kbps
Writing application                      : Lavf54.63.104

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L4.0
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Format settings, GOP                     : M=4, N=32
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1mn 58s
Bit rate mode                            : Variable
Bit rate                                 : 4 394 Kbps
Maximum bit rate                         : 20.0 Mbps
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 59.940 fps
Minimum frame rate                       : 59.920 fps
Maximum frame rate                       : 59.960 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.080
Stream size                              : 62.3 MiB (92%)
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Mode extension                           : CM (complete main)
Format settings, Endianness              : Big
Codec ID                                 : ac-3
Duration                                 : 2mn 0s
Bit rate mode                            : Constant
Bit rate                                 : 384 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
Compression mode                         : Lossy
Stream size                              : 5.49 MiB (8%)

如果有人发现了这个,我找到了答案。我没有在关键帧处进行剪切。一旦我改为在关键帧上标记所有内容,我所有的剪切都很好,音频保持同步。