[Libav-user] FFmpeg Audio Play
anshul
anshul.ffmpeg at gmail.com
Wed Apr 16 12:41:45 CEST 2014
On 04/16/2014 03:55 PM, Yamusani Vinay wrote:
> Thanks for the reply,I checked it got some what I need I have another
> doubt here in avio_reading.c it is directly mapping file to a byte
> array but what I need is,to ffmpeg I need to pass a sample byte array
> with some values i.e then ffmpeg need to play those bytes.
>
> I tried with the following code:
>
> what I did is I am passing a byte array which contains some values
> from my java code and copying that to uint *buffer_temp and assigned
> it to bd
>
> struct buffer_data {
>
> uint8_t *ptr;
>
> size_tsize; ///< size left in the buffer
>
> };
>
>
> struct buffer_data bd = { 0 };
>
>
> jbyte *bytesTemp = (*env)->GetByteArrayElements(env, inputArray,NULL);
>
> buffer_temp = av_malloc(length);
>
> memcpy(buffer_temp,bytesTemp,length);
>
> bd.ptr = buffer_temp;
>
> bd.size = length;
>
>
> fmt_ctx->pb = bd;
>
> from here I am trying to open file by using below code
>
> if ((ret = avformat_open_input(&fmt_ctx, NULL, NULL, &m_iFormatOpts)) < 0)
>
> {
>
> LOGE("Cannot open input file\n");
>
> return;
>
> }
>
>
> then I am getting ret <0
>
>
> So please help me in solving this problem.
>
>
> Thanks & Regards,
>
> Vinay.
>
>
>
> On Mon, Apr 14, 2014 at 11:12 AM, Anshul <anshul.ffmpeg at gmail.com
> <mailto:anshul.ffmpeg at gmail.com>> wrote:
>
> Yamusani Vinay <yamusanivinay at gmail.com
> <mailto:yamusanivinay at gmail.com>> wrote:
> >Hi All,
> >
> >I am developing an android app where I need to play music.I know
> how to
> >play audio using ffmpeg by giving the audio path.but my problem is in
> >my
> >application I will get audio stream in the form of bytes.So anyone
> >please
> >help me in playing these audio bytes using ffmpeg.
> >
> >input:audio stream in the form of bytes.
> >
> >Thanks,
> >Vinay Yamusani.
> >
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >Libav-user mailing list
> >Libav-user at ffmpeg.org <mailto:Libav-user at ffmpeg.org>
> >http://ffmpeg.org/mailman/listinfo/libav-user
>
>
> Since u have posted at libav I consider you would be using library
> not ffmpeg binary.
>
> You should start with avio_ reading.c example at doc/examples.
>
>
> -Anshul
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org <mailto:Libav-user at ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
Please don't top Post, Its consider rude.
I think you missed some thing from example.
pb is not the buffer where you can copy your audio data.
In pb you need to register a callback function which will be called when
ffmpeg library require data.
here is how this is done....
avio_ctx = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size,
0, &bd, &read_packet, NULL, NULL);
if (!avio_ctx) {
ret = AVERROR(ENOMEM);
goto end;
}
fmt_ctx->pb = avio_ctx;
-Anshul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20140416/b6e5ca47/attachment.html>
More information about the Libav-user
mailing list