4 #include "libavformat/avformat.h"
5 #include "libavdevice/avdevice.h"
12 static const char *vdev = "/dev/video0";
13 static const char *dst = "224.10.20.30";
14 static int dport = 20000;
15 static int width = 352;
16 static int height = 288;
19 static void sdp_print(AVFormatContext *s)
24 f = fopen("sdp.txt", "w");
25 avf_sdp_create(&s, 1, sdp, sizeof(sdp));
26 fprintf(f, "%s\n", sdp);
30 static int args_parse(int argc, char *argv[])
34 while ((v = getopt(argc, argv, "w:h:r:d:")) >= 0) {
40 height = atoi(optarg);
52 fprintf(stderr, "%s: illegal option %c\n", argv[0], v);
60 int main(int argc, char *argv[])
62 AVFormatContext *s, *os;
65 avcodec_register_all();
67 avdevice_register_all();
69 args_parse(argc, argv);
71 s = open_input_stream(vdev, width, height, fps);
73 fprintf(stderr, "Cannot open input file %s\n", vdev);
78 os = open_output_stream(dst, dport, CODEC_TYPE_VIDEO);
80 fprintf(stderr, "Cannot open output stream\n");
84 os->streams[0]->codec->width = s->streams[0]->codec->width;
85 os->streams[0]->codec->height = s->streams[0]->codec->height;
86 os->streams[0]->codec->time_base = s->streams[0]->codec->time_base;
87 codec_connect(s->streams[0]->codec, os->streams[0]->codec);
89 dump_format(os, 0, os->filename, 1);
94 pkt = read_input_packet(s);
101 pkt->pts += s->streams[pkt->stream_index]->start_time;
102 rt_job_start(pkt->pts);
103 f = pkt_decode(s, pkt);
105 opkt = pkt_encode(os, f);