[Libav-user] url_open_buf, how to get the length of the used buffer ?
anubhav jain
anubhav.nitt at gmail.com
Wed Jan 11 10:04:40 CET 2012
Hi,
I wanted to use url_open_buf to write frames into it. I wrote a sample code
for this, which is working fine with url_fopen . But i want to write into a
file from buffer at the end of processing and in between of the processing
use only buffer.
uint8_t * buf = malloc(sizeof(uint8_t)*2048000);
....
if (url_open_buf(&output_context->pb, buf, 2048000, URL_WRONLY) < 0)
{
fprintf(stderr, "Segmenter error: Could not open '%s'\n",
output_filename);
exit(1);
}
... if (av_write_header(output_context))
{
fprintf(stderr, "Segmenter error: Could not write mpegts header to
first output file\n");
exit(1);
}
.....
ret = av_interleaved_write_frame(output_context, &packet);
if (ret < 0)
{
fprintf(stderr, "Segmenter error: Could not write frame of stream:
%d\n", ret);
}
.....
if (segment_time - prev_segment_time >= config.segment_length)
{
av_write_trailer(output_context);
FILE *fp = fopen("temp.ts", "w");
int si = url_close_buf(output_context->pb);
printf("content %d", si); //this is always 0
fwrite(buf, sizeof(uint8_t), 1000000, fp);
fclose(fp);
exit(0);
}
When i use url_fopen its working fine . but i want to use buffer as a
stream.
How can i get the length of the buffer to write into a file?
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120111/b49f09a6/attachment.html>
More information about the Libav-user
mailing list