2

I have a .mov video file, for which ffprobe/avprobe reports:

$ avprobe -show_streams test.mov

    Stream #0.0(eng): Video: dvvideo, yuv420p, 720x576 [PAR 64:45 DAR 16:9], 28811 kb/s, PAR 236:162 DAR 295:162, 25.01 fps, 2500 tbn, 25 tbc
    Metadata:
      creation_time   : 2015-08-27 09:10:44
    Stream #0.1(eng): Audio: pcm_s16le, 48000 Hz, 1 channels, s16, 768 kb/s
    Metadata:
      creation_time   : 2015-08-27 09:10:44
    Stream #0.2(eng): Audio: pcm_s16le, 48000 Hz, 1 channels, s16, 768 kb/s
    Metadata:
      creation_time   : 2015-08-27 09:10:44
    Stream #0.3(eng): Data: tmcd / 0x64636D74
Unsupported codec with id 0 for input stream 3
...
[streams.stream.1]
index=1
codec_name=pcm_s16le
codec_long_name=PCM signed 16-bit little-endian
codec_type=audio
codec_time_base=1/48000
codec_tag_string=sowt
codec_tag=0x74776f73
sample_rate=48000.000000
channels=1
bits_per_sample=16
...
[streams.stream.2]
index=2
codec_name=pcm_s16le
codec_long_name=PCM signed 16-bit little-endian
codec_type=audio
codec_time_base=1/48000
codec_tag_string=sowt
codec_tag=0x74776f73
sample_rate=48000.000000
channels=1
bits_per_sample=16
...
[streams.stream.3]
index=3
codec_name=unknown
codec_type=data
codec_time_base=0/1
codec_tag_string=tmcd
codec_tag=0x64636d74
avg_frame_rate=0/0
time_base=1/2500
start_time=0.000000
duration=32.760000
nb_frames=1
...

Now, from this I cannot tell how the audio is encoded (if it isn't uncompressed), and I cannot tell whether these three audio streams are some sort of a surround sound (and one of them cannot be detected either) - but I guess they are because mediainfo reports for the same file:

Audio #1 ...
Codec ID                                 : sowt
Channel(s)                               : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
...
Audio #2 ...
Codec ID                                 : sowt
Channel(s)                               : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
...
Audio #3 ...
Muxing mode, more info                   : Muxed in Video #1
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
...

So, is there a Linux command line that I could use, to extract all of these audio streams from the video file in one go; that is, this pseudocode command:

my_command --extract-all-audio-streams test.mov

... should result, in this case, with three audio files corresponding to the three streams.

In particular:

  • What command could I use, so that the streams are extracted unconverted from the file, akin to -acodec copy of ffmpeg - and so that file extensions are automatically assigned (i.e. if it is uncompressed audio, then .wav, if it is AAC encoded, then .aac etc)
  • What command could I use, so that the streams are extracted converted as uncompressed audio, of the same settings as the streams? That is, the resulting test_s01.wav would be mono/48.0 KHz/16 bits, test_s02.wav would be also mono/48.0 KHz/16 bits, and test_s03.wav would be stereo/48.0 KHz/16 bits?
2
  • 1
    I have no way to check it here. Does ffmpeg -i test.mov -vn -map 0:1 -acodec copy -y track1.wav give you track 1?
    – infixed
    Mar 28, 2016 at 20:25
  • Thanks @infixed - indeed, it does give me track 1; btw I did find some sort of a solution with ffmpeg (for me avconv), see my post below. Cheers!
    – sdaau
    Mar 28, 2016 at 20:45

1 Answer 1

0

Well found something with ffmpeg/avconv and .wav files; it's not exactly automatic, but it is a one-liner extracting the audio. First, use ffprobe/avprobe as in OP, or ffmpeg -i/avconv -i to get the stream info; from the OP:

Stream #0:0(eng): Video:
Stream #0:1(eng): Audio:
Stream #0:2(eng): Audio:
Stream #0:3(eng): Data:

So, the Audio streams are 0:1 and 0:2 (note ffprobe/avprobe writes dot . as separator, ffmpeg -i/avconv -i writes a colon :), and those we want saved as .wav files - so this is the command:

avconv -i test.mov \
  -map '0:1' -vn -acodec copy test-01.wav \
  -map '0:2' -vn -acodec copy test-02.wav

... and at least in this case of mine, the resulting wavs have identical properties with the streams:

$ mediainfo *.wav
...
Channel(s)                               : 1 channel
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
...
Channel(s)                               : 1 channel
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits

It now looks to me like these two "mono" "center" channels are actually left and right channels - and the stream 3, even if it's called "Audio", it's still type "data", and so maybe it is just a descriptor of how these L and R mono channels are muxed (as per the mediainfo report "Muxing mode, more info")?!

Still, it would be great to know if there is a tool that could do this sort of stuff automatically...


I would have thought that one has to use filters, so I've tried this:

avconv -i test.mov -filter_complex '[0:1] copy [a1]; [0:2] copy [a2]' \
-map '[a1]' -acodec copy test-01.wav \
-map '[a2]' -acodec copy test-02.wav
... but this fails with Stream specifier ':1' in filtergraph description [0:1] copy [a1]; [0:2] copy [a2] matches no streams., don't really understand why.

4
  • 1
    Again, I can't try it now, but if you converted the file to mkv format say with mkvmerge -o tmp.mkv test.mov, you might just be able to pull all the tracks out separately with mkvextract tracks tmp.mkv
    – infixed
    Mar 28, 2016 at 21:09
  • Neat tip, @infixed, will keep it in mind; cheers!
    – sdaau
    Mar 28, 2016 at 21:11
  • The tmcd data track is a timed metadata track and not audio. sowt is twos backwards and is just a label devised by Apple to indicate little-endian 2-byte (16 bits) uncompressed PCM audio, same as PCM in WAV on Windows.
    – Gyan
    Mar 29, 2016 at 15:26
  • the data track is something else (another MOV track). Here, the 3rd audio track seen in MediaInfo is the audio stream inside the DV stream, not detected by FFmpeg. Demux the DV stream, play it and you'll hear this "hidden" audio stream (yes, you DV video stream is demuxed but you get audio. DV is a "compound" format, with video and audio together) Apr 1, 2016 at 17:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .