0

I'm trying to extract a segment from an .mpg file using ffmpeg, using this command.

ffmpeg -ss 0:00:06 -t 0:01:39 -i capture(0).mpg -vcodec copy -acodec copy test.mpg

The input file has both video and audio, but the resulting file has only video--no audio. I verified this in VLC Player and ffplay.exe. What am I missing?

This is the output of the above ffmpeg command:

Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mpeg, from 'capture(0).mpg':
  Duration: 01:06:14.08, start: 0.224400, bitrate: 9680 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0xa0]: Audio: pcm_dvd, 48000 Hz, stereo, s16, 1536 kb/s
File 'test.mpg' already exists. Overwrite ? [y/N] y
[mpeg @ 0000028434ef5c40] VBV buffer size not set, using default size of 130KB
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
Output #0, mpeg, to 'test.mpg':
  Metadata:
    encoder         : Lavf57.71.100
    Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, top first), 720x480 [SAR 8:9 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 29.97 tbc
    Stream #0:1: Audio: pcm_dvd, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 2977 fps=915 q=-1.0 Lsize=  119500kB time=00:01:39.22 bitrate=9866.2kbits/s speed=30.5x
video:100235kB audio:18659kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.510136%

ffplay console output (on the resulting output file):

[mp2 @ 00000181ee26fee0] Header missingvq=    0KB sq=    0B f=0/0
    Last message repeated 8 times
...many similar results omitted here
[mp2 @ 00000181ee26fee0] Header missingvq=    0KB sq=    0B f=0/0
    Last message repeated 9 times
[mpeg @ 00000181ee25b400] decoding for stream 1 failed
[mpeg @ 00000181ee25b400] Could not find codec parameters for stream 1 (Audio: mp2, 0 channels, s16p): unspecified frame size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpeg, from 'test.mpg':
  Duration: 00:01:39.47, start: 0.500000, bitrate: 9841 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x1c0]: Audio: mp2, 0 channels, s16p
   3.98 M-V: -0.032 fd=   4 aq=    0KB vq=  988KB sq=    0B f=0/0

I am able to get both video and audio if I change the audio codec and container format, using the following options, e.g.:

 video codec: copy     audio codec: aac         output file .mkv
 video codec: copy     audio codec: aac         output file .mp4
 video codec: copy     audio codec: libopus     output file .mkv

However, I prefer to just copy the streams for performance reasons.

1

Until very recently (2018-02-17), ffmpeg wasn't able to correctly remux pcm_dvd streams in MPEG-PS. You'll have to upgrade to a recent version. Get a git snapshot binary from FFmpeg (under More Downloading Options)

You can also just re-encode using -acodec pcm_s16be

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.