2 * Copyright (c) 2008 Luca Abeni
4 * This is free software; see GPL.txt
9 #include <libavformat/avformat.h>
10 #include <libavdevice/avdevice.h>
11 #include <libswscale/swscale.h>
18 static const char *sdp_file = "sdp.txt";
19 static const char *vdev = "/dev/video0";
20 static const char *dst = "224.10.20.30";
21 static int dport = 20000;
22 static int width = 352;
23 static int height = 288;
26 static void sdp_print(AVFormatContext *s, const char *fname)
31 f = fopen(fname, "w");
32 avf_sdp_create(&s, 1, sdp, sizeof(sdp));
33 fprintf(f, "%s\n", sdp);
37 static int args_parse(int argc, char *argv[])
41 while ((v = getopt(argc, argv, "w:h:r:d:")) >= 0) {
47 height = atoi(optarg);
59 fprintf(stderr, "%s: illegal option %c\n", argv[0], v);
67 int main(int argc, char *argv[])
69 AVFormatContext *s, *os;
72 avcodec_register_all();
74 avdevice_register_all();
76 args_parse(argc, argv);
78 s = open_input_stream(vdev, width, height, fps);
80 fprintf(stderr, "Cannot open input file %s\n", vdev);
85 os = open_output_stream(dst, dport, CODEC_TYPE_VIDEO);
87 fprintf(stderr, "Cannot open output stream\n");
91 os->streams[0]->codec->width = s->streams[0]->codec->width;
92 os->streams[0]->codec->height = s->streams[0]->codec->height;
93 os->streams[0]->codec->time_base = s->streams[0]->codec->time_base;
94 codec_connect(s->streams[0]->codec, os->streams[0]->codec);
96 dump_format(os, 0, os->filename, 1);
97 sdp_print(os, sdp_file);
101 pkt = read_input_packet(s);
108 pkt->pts += s->streams[pkt->stream_index]->start_time;
109 //rt_job_start(pkt->pts);
110 f = pkt_decode(s, pkt);
112 opkt = pkt_encode(os, f);