Re: is it possible to read a video from bytearrayinstead of a file?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Re: is it possible to read a video from bytearrayinstead of a file?

Jiawen Chen
(I'm sorry if this message ends up in a different thread, I wasn't a
member of the list before and somehow didn't get a reply in my mailbox.
  I dug the reply out of the archives.)

Thanks for the quick response.  Is there any chance there are some code
examples I can look at?

For instance, I have no idea how big the buffer should be and how much
of it gets consumed every time I read a packet...



----- Original Message -----

The problem I found while implementing this approach was that using
AVFMT_NOFILE meant no seeking support.  I ended up using a custom
URLProtocol and not specifying the AVFMT_NOFILE flag.


----- Original Message -----
From: "Stream Alerts Support" <support at>
To: <libav-user at>
Sent: Tuesday, May 27, 2008 9:47 AM
Subject: Re: [libav-user] is it possible to read a video from
bytearrayinstead of a file?

-------- Original Message --------
 > From: Torsten B├╝chner <torsten.buechner at>
 > Sent: Tuesday, May 27, 2008 9:39 AM
 > To: Libav* user questions and discussions <libav-user at>
 > Subject: [libav-user] is it possible to read a video from bytearray
 > instead of a file?
 > Hi,
 > i'am wondering if it is possible to open a video from bytearray
 > instead of a file so
 > when another part of my programm creates a video, i don't have to save
 > it on Disk.
 > At the moment i am working with av_open_input_file
 > torsten

It is possible. You need to create an AVFormatContext and then load your
data into AVFormatContext->pb->buffer. Set AVFormatContext->flags to
AVFMT_NOFILE and then use av_open_input_stream() to open the feed. After
that you need to initialize your codecs and manually reset and feed data
into that buffer after each time you read a packet. That should get you
started. Good luck!

-------- Original Message --------
From: Jiawen Chen jiawen_at_csail_dot_mit_dot_edu

Hello all,

        I'm wondering if it's possible to use libav* to directly read data from
a DV (a Sony HDV, not IIDC) camera connected over FireWire.  Or if not,
what would be the right library to use.  I'm essentially trying to get
rgb arrays into my app.

Here's what I've tried:

1. At the moment, I already have everything set up to read a raw .dv
file output from dvgrab, which works marvelously:

$ dvgrab -frames 24 foo-
$ ./myapp foo-

And it starts reading the files and works great.

2. I tried piping the data from dvgrab to stdout and reading it:

$ dvgrab - | mplayer - -demuxer lavf -lavfdopts format=dv


$ dvgrab - | xine -D stdin://#demux:rawdv

Both work marvelously.  As far as I understand, both mplayer and xine
use ffmpeg/libav* as their backends, so I should be able to replicate
the functionality.

3. I tried using the code from Martin Boehme's webpage to directly read
/dev/dv1394 but didn't have any luck:

      // ...
      int retVal;

      AVFormatContext* pFormatContext;
      AVCodecContext* pCodecContext;

      AVFormatParameters formatParams;
      AVInputFormat* inputFormat;

      formatParams.device = "/dev/dv1394"; = 0;
      formatParams.standard = "ntsc";
      formatParams.width = 720;
      formatParams.height = 480;
      filename = "";

      printf( "calling av_find_input_format\n" );
      inputFormat = av_find_input_format( "dv1394" );

      printf( "about to open file" );
      retVal = av_open_input_file
          inputFormat, 0, &formatParams
      // ...

And I get an error message:

calling av_find_input_format
about to open file
Failed to open DV interface: No such file or directory

Am I on the right track?

4. Finally, I also tried using ffmpeg from the command line and I'm
getting a similar error.  I'm following the commands from this

And am using the ffmpeg that's bundled with Ubuntu 8.04

$ sudo ffmpeg -f dv1394 -i /dev/dv1394/0 -f dv -acodec copy -vcodec copy
-y t1.avi
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
    configuration: --enable-gpl --enable-pp --enable-swscaler
--enable-pthreads --enable-libvorbis --enable-libtheora --enable-libogg
--enable-libgsm --enable-dc1394 --disable-debug --enable-shared
    libavutil version: 1d.49.3.0
    libavcodec version: 1d.51.38.0
    libavformat version: 1d.51.10.0
    built on Mar 12 2008 14:31:53, gcc: 4.2.3 (Ubuntu 4.2.3-2ubuntu4)
Failed to initialize DV interface: Invalid argument
/dev/dv1394/0: I/O error occured
Usually that means that input file is truncated and/or corrupted.



libav-user mailing list
libav-user at
libav-user mailing list
[hidden email]