我需要删除B-Frames并为mpeg添加静音音轨。这是我的源文件(mediainfo input.mpg):
General
Complete name : input.mpg
Format : MPEG-PS
File size : 3.88 MiB
Duration : 4s 0ms
Overall bit rate : 8 131 Kbps
Writing library : encoded by TMPGEnc (ver. 2.525.64.184)
Video
ID : 224 (0xE0)
Format : MPEG Video
Format version : Version 1
Format settings, BVOP : Yes
Format settings, Matrix : Default
Format settings, GOP : M=3, N=9
Duration : 4s 0ms
Bit rate : 8 000 Kbps
Width : 800 pixels
Height : 600 pixels
Display aspect ratio : 4:3
Frame rate : 30.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.556
Time code of first frame : 00:00:00:00
Time code source : Group of pictures header
GOP, Open/Closed : Open
GOP, Open/Closed of first frame : Closed
Stream size : 3.80 MiB (98%)
Writing library : TMPGEnc 2.525.64.184
我正在尝试:
ffmpeg -f lavfi -i anullsrc -i input.mpg -c:v mpeg1video -b:v 8000k \
-minrate 8000k -maxrate 8000k -pix_fmt yuv420p -g 9 -acodec mp2 \
-ac 2 -ab 128k -ar 44100 -async 1 -shortest -y out.mpg
mediainfo out.mpg
General
Complete name : out.mpg
Format : MPEG-PS
File size : 3.96 MiB
Duration : 4s 23ms
Overall bit rate : 8 251 Kbps
Video
ID : 224 (0xE0)
Format : MPEG Video
Format version : Version 1
Format settings, BVOP : No
Format settings, Matrix : Default
Format settings, GOP : N=9
Duration : 4s 0ms
Bit rate : 8 000 Kbps
Width : 800 pixels
Height : 600 pixels
Display aspect ratio : 4:3
Frame rate : 30.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.556
Time code of first frame : 00:00:00:00
Time code source : Group of pictures header
GOP, Open/Closed : Open
GOP, Open/Closed of first frame : Closed
Stream size : 3.80 MiB (96%)
Audio
ID : 192 (0xC0)
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 2
Duration : 4s 23ms
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 2 channels
Sampling rate : 44.1 KHz
Compression mode : Lossy
Delay relative to video : -11ms
Stream size : 62.9 KiB (2%)
不幸的是,音频持续时间与视频持续时间不同,并且存在一些“相对于视频的延迟”-11ms 我在另一篇文章中找到了这个选项:
-af asetpts=PTS+0.011/TB
给了我这个输出:
Audio
ID : 192 (0xC0)
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 2
Duration : 3s 997ms
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 2 channels
Sampling rate : 44.1 KHz
Compression mode : Lossy
Stream size : 62.5 KiB (2%)
这个很接近,但仍然不是我所期望的“4s 0ms”。我怎么能够 添加一个具有“绝对准确”持续时间的静音音轨?我是否正确编码视频?
答案 0 :(得分:1)
尝试
ffmpeg -f lavfi -i aevalsrc=0|0:d=4.00 -i input.mpg -c:v mpeg1video -b:v 8000k \
-minrate 8000k -maxrate 8000k -pix_fmt yuv420p -g 9 -acodec mp2 \
-ac 2 -ab 128k -ar 44100 -async 1 -shortest -y out.mpg