Reputation: 41
I need to remove the B-Frames and also add a silent audio track to an mpeg. This is my source file (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
I'm trying it with:
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%)
Unfortunately is the audio duration different to the video duration and there is some "Delay relative to video" of -11ms I found in another post this option:
-af asetpts=PTS+0.011/TB
which gives me this output:
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%)
This one is close but still not my "4s 0ms" what I expected. How can I add a silent audio track with the "absoutly exact" duration? And do I encode the video right?
Upvotes: 0
Views: 829
Reputation: 93369
Try
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
Upvotes: 1