ffmpegmpeg

(ffmpeg) VBV buffer size not set - MPG to MPG


I have a MPG file (mpeg2) with two audio streams.

I just want to remove one of the audio stream without re-encode or quality loss.

Here's my command (I don't -map the audio I want to delete) :

ffmpeg -i input.MPG
-map 0:v:0 -map 0:a:1
-vcodec mpeg2video
-c:a mp2
-y
output.MPG

It works BUT I have this error / warning :

[mpeg @ 0000020268f9a300] VBV buffer size not set, using default size of 230KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size

And of course, the quality of the output video is just terrible !

How can I fix this ?

Thanks a lot for your answers ;)


Solution

  • If you want to remove one stream in your media, copy everything BUT the stream you want to remove.

    Finding all streams inside media

    You get all the streams inside your media with this:

    ffprobe mediafile.mpg 2>&1 | grep -i stream
    

    Example

    This is an example output of one of my media:

    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 171 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 55 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
    Stream #0:2(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Stream #0:3(deu): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 130 kb/s
    Stream #0:4(fra): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s
    

    It has two video streams (from two cameras) and three audio streams (in different languages).

    How to copy (lossless)

    Now, if you want to copy a stream, you need the word copy as a codec. Example:

    ffmpeg -i media.mpg -c copy output.mkv
    

    or more explicit (video and audio codec)

    ffmpeg -i media.mpg -c:v copy -c:a copy output.mkv
    

    As a standard this will copy only the first video stream, the first audio stream, the first subtitle stream etc.

    To copy all streams :

    ffmpeg -i media.mpg -map 0 -c copy output.mkv
    

    Note: mkv is a modern media container (avi and mpg are quite old and outdated, mp4 is also newer, but mkv is more flexible). But you can also use mpg container as output.

    Remove stream

    Now I will show you how to select the streams to copy with my example media file from above. The other streams will be omitted (= removed):

    ffmpeg -i media.mkv -c copy -map 0:0 -map 0:2 -map 0:3 output.mkv
    

    As you have seen above, I had two video streams (0:0 and 0:1), and three audio streams (0:2, 0:3, 0:4). In my command I have omitted stream 0:1 and 0:4 (I removed them).

    Your case

    For your case you should have 0:0 (video) and 0:1 (audio) and 0:2 (audio):

    ffmpeg input.mpg -c copy -map 0:0 -map 0:1 output.mpg