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

Hello list,

I try to encode data from one buffer (32bit float or S16 int) to an ogg
vorbis stream that I need in another buffer (not a file). When decoding
I did it like this:
1. Implement a READ-function that returns encoded data
2. Allocate a buffer SIZE + FF_INPUT_BUFFER_PADDING_SIZE
3. (init_put_byte(&bio_ctx, BUF, SIZE, 0, (void*)opaque, &READFUNCTION,
NULL, NULL)
4. bio_ctx.is_streamed = 1
5. fmt = av_find_input_format("SOMEFORMAT")
- -- Eventually detect streams in file and use the first one --
6. av_open_input_stream(&fmt_ctx, &bio_ctx, "", fmt, NULL); where
fmt_ctx will be allocated by libavformat
7. AVCodec codec = avcodec_find_decoder(CODEC_ID_SOMETHING);
8. AVCodecContext *codec_ctx = avcodec_alloc_context();
9. avcodec_open(codec_ctx, codec);

And then in a loop:
av_read_frame(fmt_ctx, &pkt); where pkt is of type AVPacket
avcodec_decode_audio3(codec_ctx, outbuf, &outsize, &pkt);

This all works pretty well. Encoded data is requested via my
READ-function when I call av_read_frame. Decoded data is put into outbuf.
Now I tried to to the encoding-part in the same manner. Implement a
WRITE-function that handles the data in the buffer it gets when I use
av_write_frame(). Make a ByteIOContext with that function, create a
AVFormatContext, add a stream to it. Open the stream (for writing) and
pass the format context and the ByteIOContext to it and then (in a loop):
size = avcodec_encode_audio(codec_ctx, OUTBUF, sizeof(OUTBUF), (short
*)INBUF);
set AVPacket pkt.data to OUTBUF and pkt.size to size
av_write_frame(fmt_ctx, &pkt)

Now the main problem is that I didn't find a function that relates to
"av_open_input_stream". I tried setting fmt_ctx.pb = bio_ctx and
allocating space for the private data structures but I failed getting
segfaults when I tried to run it.

Encoding some data from one buffer to plain Vorbis is not that much a
problem. Somehow I get "qtice: libavutil/mathematics.c:79:
av_rescale_rnd: Assertion `c > 0' failed." there :(

Any ideas on how to achieve this?

Best regards,
        Jannis

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

iEYEARECAAYFAkziqlkACgkQeYlewm37lbj1DACfWhCOEIX3F3b9cMqx/gpbXsnz
QT0An12/KVIEGNPxUfIIvbbngazpetuL
=3WM7
-----END PGP SIGNATURE-----
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to