-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello list,

I would like to pick up an old thread
(http://www.mail-archive.com/[email protected]/msg03746.html)
since I have a similar problem. Sadly there has been no solution in the
old thread. I have a C++/Qt4 program that plays several audio files in a
loop (Each "player" gets its own thread). I used to have
"av_open_input_file" and that worked on the first file but SEGFAULTed on
some later files (somewhere in a *probe*-function called by
av_open_input_file). To avoid this, I use a custom read-function,
ByteIOContext and av_open_input_stream. All is fine when I set the file
format and codec static in my code. MP3-files are played perfectly.
However I wanted to detect the format automatically (there might be
OggVorbis files in the folder). The code to do the detection is:

inputfile->open(QIODevice::ReadOnly);
uint8_t *buffer;
buffer = (uint8_t*) malloc (4096 + AVPROBE_PADDING_SIZE);
bzero(buffer, 4096 + AVPROBE_PADDING_SIZE);
AVProbeData   pd;
//pd.filename = playfile.canonicalFilePath().toUtf8().constData();
pd.filename = "";
pd.buf = buffer;
pd.buf_size = 4096;
fmt = 0;
qDebug() << "MUSICPLAYER: Pre-probe! fmt = " << fmt;
inputstream->readRawData((char *)buffer, 4096);
if( !( fmt = av_probe_input_format( &pd, 1 ) ) ) {
  qWarning() << "MUSICPLAYER: Input format cannot be detected!";
}
qDebug() << "MUSICPLAYER: Post-probe! fmt = " << fmt << "Name:" <<
fmt->long_name;
free(buffer);

On the first file, this works perfectly. It detects the format, I can
look for streams, open the codecs and start decoding. On the second
file, this fails. When using two Ogg Vorbis files, the first gets
detected as Ogg-format, the second one will leave fmt as 0x0. The buffer
looks okay in a debugger. Both times, the first 4 bytes of buffer read
"OggS".
If both files are MP3s, the first one gets detected as MP3 correctly,
the second one as hXXX-file. I did not check the buffer contents in that
case.

Any ideas?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzCjXIACgkQeYlewm37lbiCkACfXkpsn9dbgUC1GX9RoaJiVy/q
lusAn1+ZQhKiuxm5DdMoh2Y8jRGRVQW7
=uu6A
-----END PGP SIGNATURE-----
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to