Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to move the Vorbis stream into an ogg container but ffmpeg does not seem to recognize the stream.

Even though MPlayer gives this output upon playback:

Opening audio decoder: [acm] Win32/ACM decoders
Loading codec DLL: 'vorbis.acm'
Loaded DLL driver vorbis.acm at 10000000
Warning! ACM codec reports srcsize=0
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [vorbisacm] afm: acm (OggVorbis ACM)

ffmpeg:

ffmpeg -i Source.wav -acodec copy Target.ogg
Input #0, wav, from 'Source.wav':
  Duration: 00:02:15.17, bitrate: 128 kb/s
    Stream #0.0: Audio: qg[0][0] / 0x6771, 44100 Hz, 2 channels, 128 kb/s
[ogg @ 00000000003096C0] Unsupported codec id in stream 0
Output #0, ogg, to 'Target.ogg':
  Metadata:
    encoder         : Lavf53.6.0
    Stream #0.0: Audio: qg[0][0] / 0x6771, 44100 Hz, 2 channels, 128 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Could not write header for output file #0 (incorrect codec parameters ?)

Of course this does not necessarily need to be done via ffmpeg, any method that is workable would be fine...


I have cut down one of the files to 512KB: sample.wav
(Changed two chunk size fields in the wave header to account for this, the embedded stream is cut "without notice")

share|improve this question
    
Does it actually play back correctly in MPlayer? I don't think *.wav files support vorbis streams - they should just be raw PCM data. –  Darth Android Aug 24 '12 at 22:16
    
@DarthAndroid: They do support raw data and encoding, see Wikipedia. –  H.B. Aug 24 '12 at 22:27
    
@H.B. Can you provide a sample file of the input? –  LordNeckbeard Aug 26 '12 at 20:24
    
@LordNeckbeard: I made a shorter sample from one of the files if you are still interested... –  H.B. Aug 27 '12 at 21:13
add comment

1 Answer

up vote 3 down vote accepted

The WAV container is basically just a file header. It does not support variable length frames, required by Vorbis. "OggVorbis ACM" is actually Vorbis within an Ogg container (to provide the framing) so that it can be used in the legacy Windows ACM audio framework, which does not support the required framing. This also allows it to be used in WAV files, although that doesn't make as much sense since you could just save a .ogg file instead.

ffmpeg does not implement or recognize this non-standard "OggVorbis ACM" WAV codec. You can use a program that recognizes this, such as Audacity, or you could try just stripping off the WAV header to extract the Ogg Vorbis that is inside.

Valid Ogg streams start with OggS, which marks the beginning of every Ogg Page in the file. In the file you provided there are 66 bytes before the first OggS. At least on Mac/Linux/Unix you can strip off the first 66 bytes with the command:

tail -c +67 sample.wav > sample.ogg

In your file, the embedded Ogg actually contains two streams, in what seems to be an attempt to pad it to a fixed bit rate. The second stream has an unknown codec and seems to confuse some players. For example, Firefox plays the first stream (ignoring the second) but Chrome stops when it encounters the second stream. It also has other spec violations, including no eos (end-of-stream) (perhaps because you did not post the complete file).

If you extract out the first bitstream (the vorbis one) it seems to play correctly. Here are some tools that should be able to extract the first bitstream:

  • oggsplit (works on either the wav or ogg files)
  • oggSplit from Ogg Video Tools (works on the ogg file)
  • oggz-rip (however this program does not like your file, probably due to the other spec violations)

It might be better to just read the WAV file with a program like Audacity and re-encode it to ensure that it doesn't contain any other weirdness.

share|improve this answer
    
I tried stripping the wave header before, however MPlayer will no longer play it then, and other players have trouble as well. Also for some reason the OggS can also be found in other places within the stream, see for example offset 2f196 of the sample, though i do not know much about the ogg vorbis specification... –  H.B. Aug 28 '12 at 1:47
    
OggS should be at the beginning of each Ogg Page. I've expanded on my answer to address the issue you are seeing. –  mark4o Aug 28 '12 at 7:07
    
The reencoding is exactly what i try to avoid here to not loose any more quality. Thanks for your time, i'll have a look at that approach... –  H.B. Aug 28 '12 at 11:09
    
@H.B. mark4o's solution does not re-encode, IIRC, and at least allows ffmpeg to properly decode the sample. –  LordNeckbeard Aug 28 '12 at 18:04
    
@LordNeckbeard: I know, i was just referring to the last paragraph: "It might be better to just read the WAV file with a program like Audacity and re-encode it" –  H.B. Aug 28 '12 at 18:09
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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