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视频播放器和VLC都能很好地播放视频,但我可以看到一个" hitch"在他们同步音频时,我知道音频同步的信息在某个地方的文件中。播放文件时,Mythroku和Plex都不同步。 MythTV前端播放器确实可以正确播放,我可以听到" hitch"因为它同步音频。
经过几个小时阅读帖子和玩设置后,我已经明白了这一点:
如果我说:
ffmpeg -i $file -acodec copy -vcodec copy -f mp4 -ss 0 -t <anything> out.mp4
文件很好,可以在本地和MythRoku / Plex中播放
但如果我提前开始任何数量 - 甚至1秒 - 音频不同步
ffmpeg -i $file -acodec copy -vcodec copy -f mp4 -ss 1 -t <anything> 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%)