[FFmpeg-devel] Register protocol
Phuoc Do
pdo.cloud
Mon Oct 29 03:29:44 CET 2007
Hello,
I am trying to use ffmpeg to decode stream sent over UDP. I register a new
protocol and have ffmpeg decode using this protocol. However,
av_open_input_file cannot decode the mpegts stream. With the code below, I
would get this output in stdout:
proto_open
proto_read
proto_read
proto_seek
seek to 0 - whence = 0
proto_read
proto_read
/* proto_read forever */
I use VLC to send a UDP stream encapsulated in MPEG-TS. I tried to look at
udp.c to find the answers but "ffplay udp://" hangs as well. Does ffmpeg
currently support MPEG-TS input?
Thanks,
Phuoc
Protocol.h
===
int proto_open(URLContext *h, const char *pseudofilename, int flags);
int proto_read(URLContext *h, unsigned char *buf, int size);
int proto_write(URLContext *h, unsigned char *buf, int size);
offset_t proto_seek(URLContext *h, offset_t pos, int whence);
int proto_close(URLContext* h);
static URLProtocol proto_protocol = {
"proto",
proto_open,
proto_read,
proto_write,
proto_seek,
proto_close
};
===
Protocol.cpp
int proto_open(URLContext *h, const char *pseudofilename, int flags)
{
printf("proto_open\n");
/* init UDP socket */
}
int proto_read(URLContext *h, unsigned char *buf, int size)
{
printf("proto_read\n");
socklen_t from_len;
int len = 0;
unsigned char *buf_ptr = buf;
from_len = sizeof(my_addr);
len = recvfrom (sockfd, buf, size, 0,
(struct sockaddr *)&my_addr, &from_len);
return len;
}
int proto_write(URLContext *h, unsigned char *buf, int size)
{
printf("proto_write\n");
}
offset_t proto_seek(URLContext *h, offset_t pos, int whence)
{
printf("proto_seek\n");
printf("seek to %i - whence = %i\n", pos, whence);
return 1;
}
int proto_close(URLContext* h)
{
printf("proto_close\n");
/* close socket */
return 0;
}
More information about the ffmpeg-devel
mailing list