On 7/26/2010 4:20 AM, Tomas Härdin wrote:
On Mon, 2010-07-26 at 16:32 +0900, Nhat Huy wrote:
On Mon, Jul 26, 2010 at 3:54 PM, Tomas Härdin<[email protected]>wrote:
On Thu, 2010-07-22 at 23:40 +0900, Nhat Huy wrote:
On Thu, Jul 22, 2010 at 7:20 PM, Tomas Härdin<[email protected]
wrote:
On Thu, 2010-07-22 at 18:26 +0900, Nhat Huy wrote:
My input file points to a ES bitstream, that's why I can not pass a
char*
file name to av_open_input_file.
Any helps will appreciated.
Thanks.
On Thu, Jul 22, 2010 at 6:18 PM, Nhat Huy<[email protected]>
wrote:
Hi all,
I have a problem with the function av_open_input_file.
As normal , we can use it like this:
if(av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL)!=0)
return -1; // Couldn't open file
My problem is that I can not pass argv[1] into this function, now I
have to
pass a file pointer, which already is opened by fopen in another
function.
Can anyone help me with this problem ? I stuck with it.
Best regards,
Huy.
Check out how the "pipe" protocol works. Use fileno() to get the file
descriptor corresponding to the given FILE*. IIRC you do something like
"pipe:<fd>", like "pipe:0" to read from stdin.
You could also possibly hack it using named pipes, but I suspect the
above method is the easiest.
/Tomas
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
Thanks Tomas.
According to your reply.
Is the following code right ?
FILE* input;
input = fopen(filename,"rb");
fd = fileno(input);
if(av_open_input_file(&pFormatCtx, "pipe:fd", NULL, 0, NULL)!=0)
return -1; // Couldn't open file
Thank you very much.
Huy
Uhm.. You need to use sprintf(), like:
char temp[32];
sprintf(temp, "pipe:%i", fd);
if(av_open_input_file(&pFormatCtx, temp, NULL, 0, NULL)!=0)
return -1; // Couldn't open file
/Tomas
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
Hi Tomas,
Now can I pass a bit-stream buffer instead of a file in FFmpeg ? Because my
input bit-stream is stored in memory, not in a file. I stuck is this
problem.
Can I write my program like this?
int main{
unsigned char *OutBuf;
FILE* input;
input = fopen(argv[1], "rb");
fread(bitStream_buffer, 1 ,length ,input);
if(av_open_input_file(&pFormatCtx, bitStream_buffer, NULL, 0, NULL)!=0)
...........
}
Regards,
Huy.
No. I'm not sure how to handle that specific case. Are you really
reading a file to RAM or is that just an example? You need to explain
your situation more clearly, because in your initial post you said you
had a FILE pointer, which means you shouldn't need to read into any
buffer.
Btw, ffmpeg can transcode certain videos from stdin nowadays. Try
outputing your data stdout then pipe that to ffmpeg with "-" as the
input file, like "./your_program | ffmpeg -i - output.avi" and see what
happens.
/Tomas
It's possible to read from memory. I am doing that myself: I get compressed
jpeg images from google protobuf messages and have to transcode them to a video
format. It would be awfully inefficient to write the jpeg data for each frame
out to a file first.
What we did is create our own protocol. Each one has a name, which you use as
the scheme name for the URL you open. av_open_input_file() will find the
protocol implementation associated with the scheme name (which is what you
write), and use it for I/O. The rest of the URL is up to you; you can put
whatever you want in it (e.g. a pointer to an in-memory buffer....) See
av_register_protocol(), and URLProtocol.
If enough people need this kind of capability, maybe a memory buffer "protocol"
ought to be built into libav*.
Andy
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user