[Vorbis-dev] Zero length reported.

Jim Credland
Thu, 06 Apr 2017 14:43:18 -0000

Hello - I have two files which play back in VLC correctly.

They were encoded using this command:

ffmpeg -y -i
'/tmp/2e905b981d30324f9a0664cbabb3f59a20170406-21128-r0neh9.wav' -acodec
libvorbis
'/tmp/2e905b981d30324f9a0664cbabb3f59a20170406-21128-r0neh920170406-21128-146yyex.ogg

However ov_pcm_total reports a zero length for one of the two files.  Is this a
problem with my use of the ov_pcm_total function or a problem with the encoding?
The files are here http://www.credland.net/ogg/ along with a copy of the source
code.

This is a problem because the same function call is used by the JUCE ogg decoder
we are using in an application.

Any thoughts?

thanks in advance, Jim.



The output is:

jim at snoopy ~/trouble.vorbis/a
 $ ./a < 53884c2935e6b47938f91ca78b0c2473a85730833138370caedbb66a74995130.ogg
encoder=Lavf53.32.100

Bitstream is 2 channel, 44100Hz
Encoded by: Lavf53.32.100

Length: 0

jim at snoopy ~/trouble.vorbis/a
 $ ./a < d7d5ef8e6c7fad33f922924d0a05591277654d53941d43518f1fe8580c7ea3f9.ogg
encoder=Lavf53.32.100

Bitstream is 2 channel, 44100Hz
Encoded by: Lavf53.32.100

Length: 1146624


Source:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "vorbis/codec.h"
#include "vorbis/vorbisfile.h"

#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#endif

char pcmout[4096];

int main (int argc, char** argv)
{
    OggVorbis_File vf;
    int eof = 0;
    int current_section;

#ifdef _WIN32
    _setmode (_fileno (stdin), _O_BINARY);
    _setmode (_fileno (stdout), _O_BINARY);
#endif

    if (ov_open_callbacks (stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) <
0)
    {
        fprintf (stderr, "Input does not appear to be an Ogg
bitstream.\n");
        exit (1);
    }

    {
        char** ptr = ov_comment (&vf, -1)->user_comments;
        vorbis_info* vi = ov_info (&vf, -1);

        while (*ptr)
        {
            fprintf (stderr, "%s\n", *ptr);
            ++ptr;
        }

        fprintf (stderr, "\nBitstream is %d channel, %ldHz\n",
vi->channels, vi->rate);
        fprintf (stderr, "Encoded by: %s\n\n", ov_comment (&vf,
-1)->vendor);
        fprintf (stderr, "Length: %lld\n\n", ov_pcm_total(&vf,
-1));
    }

    return 0;
}