Answers.Body: <p>Until very recently (<a href="http://git.videolan.org/?p=ffmpeg.git;a=commit;h=f0809bc0fa634afe8b7c3f2682b8e51e87d0861e" rel="nofollow noreferrer">2018-02-17</a>), 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 <a href="https://ffmpeg.org/download.html" rel="nofollow noreferrer">FFmpeg</a> (under More Downloading Options)</p>
  
  <p>You can also just re-encode using <code>-acodec pcm_s16be</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-12T06:01:40.163Z
Answers.LastActivityDate: 2018-03-12T06:01:40.163Z
Answers.UserDisplayName: Gyan
Body: <p>I'm trying to extract a segment from an .mpg file using ffmpeg, using this command.</p>
  
  <pre><code>ffmpeg -ss 0:00:06 -t 0:01:39 -i capture(0).mpg -vcodec copy -acodec copy test.mpg
  </code></pre>
  
  <p>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?</p>
  
  <p>This is the output of the above ffmpeg command:</p>
  
  <pre><code>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 -&gt; #0:0 (copy)
    Stream #0:1 -&gt; #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%
  </code></pre>
  
  <p>ffplay console output (on the resulting output file):</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>I <strong>am</strong> able to get both video and audio if I change the audio codec and container format, using the following options, e.g.: </p>
  
  <pre><code> 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
  </code></pre>
  
  <p>However, I prefer to just copy the streams for performance reasons.</p>
  
Tags: <ffmpeg><mpeg>
Title: Extracting segment from .mpg file using ffmpeg; why does result have video but no audio?
UserDisplayName: Richard II
ThreadText: # Extracting segment from .mpg file using ffmpeg; why does result have video but no audio?
  
  (Asked by: username_0 on 2018-03-12)
  
  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.
  
  **Tags:** ffmpeg, mpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-03-12. Score: 1
  
  Until very recently ([2018-02-17](http://git.videolan.org/?p=ffmpeg.git;a=commit;h=f0809bc0fa634afe8b7c3f2682b8e51e87d0861e)), 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](https://ffmpeg.org/download.html) (under More Downloading Options)
  
  You can also just re-encode using `-acodec pcm_s16be`
  
  
  ---
  
  