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 #include "streamer_config.h"
20 #ifdef CONFIG_STREAMER_WITH_FRSH
24 static const char *sdp_file = "sdp.txt";
25 static const char *vdev = "/dev/video0";
26 static const char *dst = "127.0.0.1";
27 static int dport = 20000;
28 static int width = 352;
29 static int height = 288;
31 static const char *impform = "video4linux2";
33 static void sdp_print(AVFormatContext *s, const char *fname)
38 f = fopen(fname, "w");
39 avf_sdp_create(&s, 1, sdp, sizeof(sdp));
40 fprintf(f, "%s\n", sdp);
44 static int args_parse(int argc, char *argv[])
48 while ((v = getopt(argc, argv, "w:h:r:d:m:i:")) >= 0) {
54 height = atoi(optarg);
67 if(!strcmp(impform, "v4l"))
68 impform = "video4linux";
69 else if(!strcmp(impform, "v4l2"))
70 impform = "video4linux2";
73 fprintf(stderr, "%s: illegal option %c\n", argv[0], v);
81 int main(int argc, char *argv[])
83 AVFormatContext *s, *os;
86 #ifdef CONFIG_STREAMER_WITH_FRSH
88 if (ret) PERROR_AND_EXIT(ret, "frsh_init1");
89 #endif /*CONFIG_STREAMER_WITH_FRSH*/
91 avcodec_register_all();
93 avdevice_register_all();
95 args_parse(argc, argv);
97 s = open_input_stream(vdev, width, height, fps, impform);
99 fprintf(stderr, "Cannot open input file %s\n", vdev);
104 os = open_output_stream(dst, dport, CODEC_TYPE_VIDEO);
106 fprintf(stderr, "Cannot open output stream\n");
110 os->streams[0]->codec->width = s->streams[0]->codec->width;
111 os->streams[0]->codec->height = s->streams[0]->codec->height;
112 os->streams[0]->codec->time_base = s->streams[0]->codec->time_base;
113 codec_connect(s->streams[0]->codec, os->streams[0]->codec);
115 dump_format(os, 0, os->filename, 1);
116 sdp_print(os, sdp_file);
120 pkt = read_input_packet(s);
127 pkt->pts += s->streams[pkt->stream_index]->start_time;
128 //rt_job_start(pkt->pts);
129 f = pkt_decode(s, pkt);
131 opkt = pkt_encode(os, f);