[Ffmpeg-devel] Using tcp:// url as output protocol

Silvano Galliani kysucix kysucix
Fri Oct 6 15:32:21 CEST 2006


Silvano Galliani (kysucix) wrote:
> Hi.
> I would like to send my encoded video throut a tcp socket.
> I tryed with:

I found how to do it.
I post a sample code here just for archive purpose.

If you want to use an url protocol to output your encoded media (e.g. 
tcp://hostname:port) follow these instructions:

- open your favourite media format as you would open it with a file:

AVOutputformat *aof = guess_format ("avi", NULL, NULL);

- Use url_open () instead of url_fopen () and pass it an URLContext 
pointer and your url :
	url_open (url_context, "tcp://hostname:port", URL_WRONLY);

- Use url_open_dyn_buf on ByteIOContext of your AVFormatContext

	url_open_dyn_buf (&format_context -> pb)

- write your header:

	av_write_header( ... )

- send it to your url:

guchar *pb_buffer;
int len = url_close_dyn_buf(format_context -> pb, (unsigned char 
**)(&pb_buffer));
url_write (url_context, (guchar *)pb_buffer, len);


Do the same with av_write_frame:

- Use url_open_dyn_buf() on ByteIOContext of your AVFormatContext

	url_open_dyn_buf (&format_context -> pb)

- write your header:

	av_write_frame( ... )

- send it to your url:

guchar *pb_buffer;
int len = url_close_dyn_buf(format_context -> pb, (unsigned char 
**)(&pb_buffer));
url_write (url_context, (guchar *)pb_buffer, len);

Maybe this version is more readable:
http://lab.dyne.org/Ffmpeg/UseUrlProtocol
Best Regards
kysucix




More information about the ffmpeg-devel mailing list