If you want to feed data from yout own buffer.

This is what VLC does.

int cFfmpegDecoder::IO_read_packet(void *arg, uint8_t *buffer, int buf_size)
{
/// Read the data
/// do the pre-processing
}

int main()
{
   uint8_t    buffer[bufsize];
   AVProbeData   pd;
   pd.filename = ".ts";
   pd.buf = buffer;
   pd.buf_size = bufsize;

   // Read a tini bit of the input.
   IO_read_packet(this, buffer, bufsize);

   // Check input format
   if( !( fmt = av_probe_input_format( &pd, 1 ) ) )
       throw ("Can't find input format");

   cout << "Video Format: " << fmt->name << endlog;

   // Init io module for input
   init_put_byte( &io, buffer, bufsize, 0, this, IO_read_packet, 0, 0 );
   memset(&params, 0, sizeof(params));

   if( av_open_input_stream( &ic, &io, "", fmt, &params ) )
       throw TRANSCODE_EXCEPTION("Can not open input stream");



On Mon, Mar 9, 2009 at 7:19 AM, Ronald S. Bultje <[email protected]> wrote:
> Hi Tom,
>
> On Mon, Mar 9, 2009 at 2:30 AM, Tom Handal <[email protected]> wrote:
>> I was wondering if there was a way I could read from the file/socket myself
>> so I can run my own pre-processing on the TS packets, then pass the TS
>> packets to a function similar to av_read_frame to proceed as normal?
>
> You can't do push-based processing, but here's something that comes
> pretty close: you can create your own URLProtocol implementation
> ("my-file"), and then make the URLProtocol.read() function be fed data
> that you've read yourself. GStreamer does it that way, it's not very
> difficult, have a look at their gstffmpegprotocol.c file. You would
> then open the protocol using av_open_input_protocol() instead of
> av_open_input_file().
>
> Ronald
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to