0

I'm trying to extract audio tracks from some Avi videos and save them to their own files, ideally without re-encoding.

I've had a look through here https://www.ffmpeg.org/ffmpeg.html#Audio-Options and here ffmpeg to extract audio from video though I'm getting errors regardless of the approach I try.

My latest command string is:

ffmpeg -i /home/d/Pictures/Test/input-video.AVI -map 0:a -vn -acodec copy /home/d/Pictures/Test/output-audio.m4a

The key part of the output is:

Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, avi, from '/home/d/Pictures/Test/input-video.AVI':
  Duration: 00:00:05.94, start: 0.000000, bitrate: 18131 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 1280x720, 17995 kb/s, 30.28 fps, 30.28 tbr, 30.28 tbn, 30.28 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 11025 Hz, 1 channels, s16, 176 kb/s
File '/home/d/Pictures/Test/output-audio.m4a' already exists. Overwrite ? [y/N] y
[ipod @ 0x1d89520] Codec for stream 0 does not use global headers but container format requires global headers
[ipod @ 0x1d89520] Could not find tag for codec pcm_s16le in stream #0, codec not currently supported in container
Output #0, ipod, to '/home/d/Pictures/Test/output-audio.m4a':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 11025 Hz, mono, 176 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

I'm believe I have got the right audio stream number from this output and thus am assuming the "-map 0:a" part isn't the problem.

I'm running on Linux Mint 18.1

Puffin
  • 139
  • 9

1 Answers1

2

MP4 family of formats don't store PCM audio, so you either have to re-encode or save to another format, like Matroska.

ffmpeg -i video.AVI -map 0:a -vn -acodec copy audio.mka
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • That's great that works well thank you. Let me understand a bit further, is PCM not actually compressed in the first place and that's why its not supported? i.e. in your example is some compression used? – Puffin May 13 '19 at 20:48
  • 1
    PCM is uncompressed, and it's not supported by ffmpeg because the file format standard (ISO 14496) doesn't support it. My command copies the stream as-is – Gyan May 14 '19 at 04:43