4 #include "libavformat/avformat.h"
5 #include "libavdevice/avdevice.h"
12 static const char *sdp_file = "sdp.txt";
13 static const char *vdev = "/dev/video0";
14 static const char *dst = "224.10.20.30";
15 static int dport = 20000;
16 static int width = 352;
17 static int height = 288;
20 static void sdp_print(AVFormatContext *s, const char *fname)
25 f = fopen("fname", "w");
26 avf_sdp_create(&s, 1, sdp, sizeof(sdp));
27 fprintf(f, "%s\n", sdp);
31 static int args_parse(int argc, char *argv[])
35 while ((v = getopt(argc, argv, "w:h:r:d:")) >= 0) {
41 height = atoi(optarg);
53 fprintf(stderr, "%s: illegal option %c\n", argv[0], v);
61 int main(int argc, char *argv[])
63 AVFormatContext *s, *os;
66 avcodec_register_all();
68 avdevice_register_all();
70 args_parse(argc, argv);
72 s = open_input_stream(vdev, width, height, fps);
74 fprintf(stderr, "Cannot open input file %s\n", vdev);
79 os = open_output_stream(dst, dport, CODEC_TYPE_VIDEO);
81 fprintf(stderr, "Cannot open output stream\n");
85 os->streams[0]->codec->width = s->streams[0]->codec->width;
86 os->streams[0]->codec->height = s->streams[0]->codec->height;
87 os->streams[0]->codec->time_base = s->streams[0]->codec->time_base;
88 codec_connect(s->streams[0]->codec, os->streams[0]->codec);
90 dump_format(os, 0, os->filename, 1);
91 sdp_print(os, sdp_file);
95 pkt = read_input_packet(s);
102 pkt->pts += s->streams[pkt->stream_index]->start_time;
103 rt_job_start(pkt->pts);
104 f = pkt_decode(s, pkt);
106 opkt = pkt_encode(os, f);