write DTS, based on patch by Luca Abeni, lucabe72 email it
[libav.git] / libavformat / mpegtsenc.c
1 /*
2 * MPEG2 transport stream (aka DVB) muxer
3 * Copyright (c) 2003 Fabrice Bellard.
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 #include "avformat.h"
22 #include "crc.h"
23 #include "mpegts.h"
24
25 /* write DVB SI sections */
26
27 /*********************************************/
28 /* mpegts section writer */
29
30 typedef struct MpegTSSection {
31 int pid;
32 int cc;
33 void (*write_packet)(struct MpegTSSection *s, const uint8_t *packet);
34 void *opaque;
35 } MpegTSSection;
36
37 /* NOTE: 4 bytes must be left at the end for the crc32 */
38 static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len)
39 {
40 unsigned int crc;
41 unsigned char packet[TS_PACKET_SIZE];
42 const unsigned char *buf_ptr;
43 unsigned char *q;
44 int first, b, len1, left;
45
46 crc = bswap_32(av_crc(av_crc04C11DB7, -1, buf, len - 4));
47 buf[len - 4] = (crc >> 24) & 0xff;
48 buf[len - 3] = (crc >> 16) & 0xff;
49 buf[len - 2] = (crc >> 8) & 0xff;
50 buf[len - 1] = (crc) & 0xff;
51
52 /* send each packet */
53 buf_ptr = buf;
54 while (len > 0) {
55 first = (buf == buf_ptr);
56 q = packet;
57 *q++ = 0x47;
58 b = (s->pid >> 8);
59 if (first)
60 b |= 0x40;
61 *q++ = b;
62 *q++ = s->pid;
63 s->cc = (s->cc + 1) & 0xf;
64 *q++ = 0x10 | s->cc;
65 if (first)
66 *q++ = 0; /* 0 offset */
67 len1 = TS_PACKET_SIZE - (q - packet);
68 if (len1 > len)
69 len1 = len;
70 memcpy(q, buf_ptr, len1);
71 q += len1;
72 /* add known padding data */
73 left = TS_PACKET_SIZE - (q - packet);
74 if (left > 0)
75 memset(q, 0xff, left);
76
77 s->write_packet(s, packet);
78
79 buf_ptr += len1;
80 len -= len1;
81 }
82 }
83
84 static inline void put16(uint8_t **q_ptr, int val)
85 {
86 uint8_t *q;
87 q = *q_ptr;
88 *q++ = val >> 8;
89 *q++ = val;
90 *q_ptr = q;
91 }
92
93 static int mpegts_write_section1(MpegTSSection *s, int tid, int id,
94 int version, int sec_num, int last_sec_num,
95 uint8_t *buf, int len)
96 {
97 uint8_t section[1024], *q;
98 unsigned int tot_len;
99
100 tot_len = 3 + 5 + len + 4;
101 /* check if not too big */
102 if (tot_len > 1024)
103 return -1;
104
105 q = section;
106 *q++ = tid;
107 put16(&q, 0xb000 | (len + 5 + 4)); /* 5 byte header + 4 byte CRC */
108 put16(&q, id);
109 *q++ = 0xc1 | (version << 1); /* current_next_indicator = 1 */
110 *q++ = sec_num;
111 *q++ = last_sec_num;
112 memcpy(q, buf, len);
113
114 mpegts_write_section(s, section, tot_len);
115 return 0;
116 }
117
118 /*********************************************/
119 /* mpegts writer */
120
121 #define DEFAULT_PMT_START_PID 0x1000
122 #define DEFAULT_START_PID 0x0100
123 #define DEFAULT_PROVIDER_NAME "FFmpeg"
124 #define DEFAULT_SERVICE_NAME "Service01"
125
126 /* default network id, transport stream and service identifiers */
127 #define DEFAULT_ONID 0x0001
128 #define DEFAULT_TSID 0x0001
129 #define DEFAULT_SID 0x0001
130
131 /* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
132 #define DEFAULT_PES_HEADER_FREQ 16
133 #define DEFAULT_PES_PAYLOAD_SIZE ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)
134
135 /* we retransmit the SI info at this rate */
136 #define SDT_RETRANS_TIME 500
137 #define PAT_RETRANS_TIME 100
138 #define PCR_RETRANS_TIME 20
139
140 typedef struct MpegTSWriteStream {
141 struct MpegTSService *service;
142 int pid; /* stream associated pid */
143 int cc;
144 int payload_index;
145 int64_t payload_pts;
146 int64_t payload_dts;
147 uint8_t payload[DEFAULT_PES_PAYLOAD_SIZE];
148 } MpegTSWriteStream;
149
150 typedef struct MpegTSService {
151 MpegTSSection pmt; /* MPEG2 pmt table context */
152 int sid; /* service ID */
153 char *name;
154 char *provider_name;
155 int pcr_pid;
156 int pcr_packet_count;
157 int pcr_packet_freq;
158 } MpegTSService;
159
160 typedef struct MpegTSWrite {
161 MpegTSSection pat; /* MPEG2 pat table */
162 MpegTSSection sdt; /* MPEG2 sdt table context */
163 MpegTSService **services;
164 int sdt_packet_count;
165 int sdt_packet_freq;
166 int pat_packet_count;
167 int pat_packet_freq;
168 int nb_services;
169 int onid;
170 int tsid;
171 } MpegTSWrite;
172
173 static void mpegts_write_pat(AVFormatContext *s)
174 {
175 MpegTSWrite *ts = s->priv_data;
176 MpegTSService *service;
177 uint8_t data[1012], *q;
178 int i;
179
180 q = data;
181 for(i = 0; i < ts->nb_services; i++) {
182 service = ts->services[i];
183 put16(&q, service->sid);
184 put16(&q, 0xe000 | service->pmt.pid);
185 }
186 mpegts_write_section1(&ts->pat, PAT_TID, ts->tsid, 0, 0, 0,
187 data, q - data);
188 }
189
190 static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
191 {
192 // MpegTSWrite *ts = s->priv_data;
193 uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr;
194 int val, stream_type, i;
195
196 q = data;
197 put16(&q, 0xe000 | service->pcr_pid);
198
199 program_info_length_ptr = q;
200 q += 2; /* patched after */
201
202 /* put program info here */
203
204 val = 0xf000 | (q - program_info_length_ptr - 2);
205 program_info_length_ptr[0] = val >> 8;
206 program_info_length_ptr[1] = val;
207
208 for(i = 0; i < s->nb_streams; i++) {
209 AVStream *st = s->streams[i];
210 MpegTSWriteStream *ts_st = st->priv_data;
211 switch(st->codec->codec_id) {
212 case CODEC_ID_MPEG1VIDEO:
213 case CODEC_ID_MPEG2VIDEO:
214 stream_type = STREAM_TYPE_VIDEO_MPEG2;
215 break;
216 case CODEC_ID_MPEG4:
217 stream_type = STREAM_TYPE_VIDEO_MPEG4;
218 break;
219 case CODEC_ID_H264:
220 stream_type = STREAM_TYPE_VIDEO_H264;
221 break;
222 case CODEC_ID_MP2:
223 case CODEC_ID_MP3:
224 stream_type = STREAM_TYPE_AUDIO_MPEG1;
225 break;
226 case CODEC_ID_AAC:
227 stream_type = STREAM_TYPE_AUDIO_AAC;
228 break;
229 case CODEC_ID_AC3:
230 stream_type = STREAM_TYPE_AUDIO_AC3;
231 break;
232 default:
233 stream_type = STREAM_TYPE_PRIVATE_DATA;
234 break;
235 }
236 *q++ = stream_type;
237 put16(&q, 0xe000 | ts_st->pid);
238 desc_length_ptr = q;
239 q += 2; /* patched after */
240
241 /* write optional descriptors here */
242 switch(st->codec->codec_type) {
243 case CODEC_TYPE_AUDIO:
244 if (strlen(st->language) == 3) {
245 *q++ = 0x0a; /* ISO 639 language descriptor */
246 *q++ = 4;
247 *q++ = st->language[0];
248 *q++ = st->language[1];
249 *q++ = st->language[2];
250 *q++ = 0; /* undefined type */
251 }
252 break;
253 case CODEC_TYPE_SUBTITLE:
254 {
255 const char *language;
256 language = st->language;
257 if (strlen(language) != 3)
258 language = "eng";
259 *q++ = 0x59;
260 *q++ = 8;
261 *q++ = language[0];
262 *q++ = language[1];
263 *q++ = language[2];
264 *q++ = 0x10; /* normal subtitles (0x20 = if hearing pb) */
265 put16(&q, 1); /* page id */
266 put16(&q, 1); /* ancillary page id */
267 }
268 break;
269 }
270
271 val = 0xf000 | (q - desc_length_ptr - 2);
272 desc_length_ptr[0] = val >> 8;
273 desc_length_ptr[1] = val;
274 }
275 mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0,
276 data, q - data);
277 }
278
279 /* NOTE: str == NULL is accepted for an empty string */
280 static void putstr8(uint8_t **q_ptr, const char *str)
281 {
282 uint8_t *q;
283 int len;
284
285 q = *q_ptr;
286 if (!str)
287 len = 0;
288 else
289 len = strlen(str);
290 *q++ = len;
291 memcpy(q, str, len);
292 q += len;
293 *q_ptr = q;
294 }
295
296 static void mpegts_write_sdt(AVFormatContext *s)
297 {
298 MpegTSWrite *ts = s->priv_data;
299 MpegTSService *service;
300 uint8_t data[1012], *q, *desc_list_len_ptr, *desc_len_ptr;
301 int i, running_status, free_ca_mode, val;
302
303 q = data;
304 put16(&q, ts->onid);
305 *q++ = 0xff;
306 for(i = 0; i < ts->nb_services; i++) {
307 service = ts->services[i];
308 put16(&q, service->sid);
309 *q++ = 0xfc | 0x00; /* currently no EIT info */
310 desc_list_len_ptr = q;
311 q += 2;
312 running_status = 4; /* running */
313 free_ca_mode = 0;
314
315 /* write only one descriptor for the service name and provider */
316 *q++ = 0x48;
317 desc_len_ptr = q;
318 q++;
319 *q++ = 0x01; /* digital television service */
320 putstr8(&q, service->provider_name);
321 putstr8(&q, service->name);
322 desc_len_ptr[0] = q - desc_len_ptr - 1;
323
324 /* fill descriptor length */
325 val = (running_status << 13) | (free_ca_mode << 12) |
326 (q - desc_list_len_ptr - 2);
327 desc_list_len_ptr[0] = val >> 8;
328 desc_list_len_ptr[1] = val;
329 }
330 mpegts_write_section1(&ts->sdt, SDT_TID, ts->tsid, 0, 0, 0,
331 data, q - data);
332 }
333
334 static MpegTSService *mpegts_add_service(MpegTSWrite *ts,
335 int sid,
336 const char *provider_name,
337 const char *name)
338 {
339 MpegTSService *service;
340
341 service = av_mallocz(sizeof(MpegTSService));
342 if (!service)
343 return NULL;
344 service->pmt.pid = DEFAULT_PMT_START_PID + ts->nb_services - 1;
345 service->sid = sid;
346 service->provider_name = av_strdup(provider_name);
347 service->name = av_strdup(name);
348 service->pcr_pid = 0x1fff;
349 dynarray_add(&ts->services, &ts->nb_services, service);
350 return service;
351 }
352
353 static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
354 {
355 AVFormatContext *ctx = s->opaque;
356 put_buffer(&ctx->pb, packet, TS_PACKET_SIZE);
357 }
358
359 static int mpegts_write_header(AVFormatContext *s)
360 {
361 MpegTSWrite *ts = s->priv_data;
362 MpegTSWriteStream *ts_st;
363 MpegTSService *service;
364 AVStream *st;
365 int i, total_bit_rate;
366 const char *service_name;
367
368 ts->tsid = DEFAULT_TSID;
369 ts->onid = DEFAULT_ONID;
370 /* allocate a single DVB service */
371 service_name = s->title;
372 if (service_name[0] == '\0')
373 service_name = DEFAULT_SERVICE_NAME;
374 service = mpegts_add_service(ts, DEFAULT_SID,
375 DEFAULT_PROVIDER_NAME, service_name);
376 service->pmt.write_packet = section_write_packet;
377 service->pmt.opaque = s;
378
379 ts->pat.pid = PAT_PID;
380 ts->pat.cc = 0;
381 ts->pat.write_packet = section_write_packet;
382 ts->pat.opaque = s;
383
384 ts->sdt.pid = SDT_PID;
385 ts->sdt.cc = 0;
386 ts->sdt.write_packet = section_write_packet;
387 ts->sdt.opaque = s;
388
389 /* assign pids to each stream */
390 total_bit_rate = 0;
391 for(i = 0;i < s->nb_streams; i++) {
392 st = s->streams[i];
393 ts_st = av_mallocz(sizeof(MpegTSWriteStream));
394 if (!ts_st)
395 goto fail;
396 st->priv_data = ts_st;
397 ts_st->service = service;
398 ts_st->pid = DEFAULT_START_PID + i;
399 ts_st->payload_pts = AV_NOPTS_VALUE;
400 ts_st->payload_dts = AV_NOPTS_VALUE;
401 /* update PCR pid by using the first video stream */
402 if (st->codec->codec_type == CODEC_TYPE_VIDEO &&
403 service->pcr_pid == 0x1fff)
404 service->pcr_pid = ts_st->pid;
405 total_bit_rate += st->codec->bit_rate;
406 }
407
408 /* if no video stream, use the first stream as PCR */
409 if (service->pcr_pid == 0x1fff && s->nb_streams > 0) {
410 ts_st = s->streams[0]->priv_data;
411 service->pcr_pid = ts_st->pid;
412 }
413
414 if (total_bit_rate <= 8 * 1024)
415 total_bit_rate = 8 * 1024;
416 service->pcr_packet_freq = (total_bit_rate * PCR_RETRANS_TIME) /
417 (TS_PACKET_SIZE * 8 * 1000);
418 ts->sdt_packet_freq = (total_bit_rate * SDT_RETRANS_TIME) /
419 (TS_PACKET_SIZE * 8 * 1000);
420 ts->pat_packet_freq = (total_bit_rate * PAT_RETRANS_TIME) /
421 (TS_PACKET_SIZE * 8 * 1000);
422 #if 0
423 printf("%d %d %d\n",
424 total_bit_rate, ts->sdt_packet_freq, ts->pat_packet_freq);
425 #endif
426
427 /* write info at the start of the file, so that it will be fast to
428 find them */
429 mpegts_write_sdt(s);
430 mpegts_write_pat(s);
431 for(i = 0; i < ts->nb_services; i++) {
432 mpegts_write_pmt(s, ts->services[i]);
433 }
434 put_flush_packet(&s->pb);
435
436 return 0;
437
438 fail:
439 for(i = 0;i < s->nb_streams; i++) {
440 st = s->streams[i];
441 av_free(st->priv_data);
442 }
443 return -1;
444 }
445
446 /* send SDT, PAT and PMT tables regulary */
447 static void retransmit_si_info(AVFormatContext *s)
448 {
449 MpegTSWrite *ts = s->priv_data;
450 int i;
451
452 if (++ts->sdt_packet_count == ts->sdt_packet_freq) {
453 ts->sdt_packet_count = 0;
454 mpegts_write_sdt(s);
455 }
456 if (++ts->pat_packet_count == ts->pat_packet_freq) {
457 ts->pat_packet_count = 0;
458 mpegts_write_pat(s);
459 for(i = 0; i < ts->nb_services; i++) {
460 mpegts_write_pmt(s, ts->services[i]);
461 }
462 }
463 }
464
465 static void write_pts(uint8_t *q, int fourbits, int64_t pts)
466 {
467 int val;
468
469 val = fourbits << 4 | (((pts >> 30) & 0x07) << 1) | 1;
470 *q++ = val;
471 val = (((pts >> 15) & 0x7fff) << 1) | 1;
472 *q++ = val >> 8;
473 *q++ = val;
474 val = (((pts) & 0x7fff) << 1) | 1;
475 *q++ = val >> 8;
476 *q++ = val;
477 }
478
479 /* NOTE: pes_data contains all the PES packet */
480 static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
481 const uint8_t *payload, int payload_size,
482 int64_t pts, int64_t dts)
483 {
484 MpegTSWriteStream *ts_st = st->priv_data;
485 uint8_t buf[TS_PACKET_SIZE];
486 uint8_t *q;
487 int val, is_start, len, header_len, write_pcr, private_code, flags;
488 int afc_len, stuffing_len;
489 int64_t pcr = -1; /* avoid warning */
490
491 is_start = 1;
492 while (payload_size > 0) {
493 retransmit_si_info(s);
494
495 write_pcr = 0;
496 if (ts_st->pid == ts_st->service->pcr_pid) {
497 ts_st->service->pcr_packet_count++;
498 if (ts_st->service->pcr_packet_count >=
499 ts_st->service->pcr_packet_freq) {
500 ts_st->service->pcr_packet_count = 0;
501 write_pcr = 1;
502 /* XXX: this is incorrect, but at least we have a PCR
503 value */
504 pcr = pts;
505 }
506 }
507
508 /* prepare packet header */
509 q = buf;
510 *q++ = 0x47;
511 val = (ts_st->pid >> 8);
512 if (is_start)
513 val |= 0x40;
514 *q++ = val;
515 *q++ = ts_st->pid;
516 *q++ = 0x10 | ts_st->cc | (write_pcr ? 0x20 : 0);
517 ts_st->cc = (ts_st->cc + 1) & 0xf;
518 if (write_pcr) {
519 *q++ = 7; /* AFC length */
520 *q++ = 0x10; /* flags: PCR present */
521 *q++ = pcr >> 25;
522 *q++ = pcr >> 17;
523 *q++ = pcr >> 9;
524 *q++ = pcr >> 1;
525 *q++ = (pcr & 1) << 7;
526 *q++ = 0;
527 }
528 if (is_start) {
529 /* write PES header */
530 *q++ = 0x00;
531 *q++ = 0x00;
532 *q++ = 0x01;
533 private_code = 0;
534 if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
535 *q++ = 0xe0;
536 } else if (st->codec->codec_type == CODEC_TYPE_AUDIO &&
537 (st->codec->codec_id == CODEC_ID_MP2 ||
538 st->codec->codec_id == CODEC_ID_MP3)) {
539 *q++ = 0xc0;
540 } else {
541 *q++ = 0xbd;
542 if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
543 private_code = 0x20;
544 }
545 }
546 header_len = 0;
547 flags = 0;
548 if (pts != AV_NOPTS_VALUE) {
549 header_len += 5;
550 flags |= 0x80;
551 }
552 if (dts != AV_NOPTS_VALUE) {
553 header_len += 5;
554 flags |= 0x40;
555 }
556 len = payload_size + header_len + 3;
557 if (private_code != 0)
558 len++;
559 *q++ = len >> 8;
560 *q++ = len;
561 val = 0x80;
562 /* data alignment indicator is required for subtitle data */
563 if (st->codec->codec_type == CODEC_TYPE_SUBTITLE)
564 val |= 0x04;
565 *q++ = val;
566 *q++ = flags;
567 *q++ = header_len;
568 if (pts != AV_NOPTS_VALUE) {
569 write_pts(q, flags >> 6, pts);
570 q += 5;
571 }
572 if (dts != AV_NOPTS_VALUE) {
573 write_pts(q, 1, dts);
574 q += 5;
575 }
576 if (private_code != 0)
577 *q++ = private_code;
578 is_start = 0;
579 }
580 /* header size */
581 header_len = q - buf;
582 /* data len */
583 len = TS_PACKET_SIZE - header_len;
584 if (len > payload_size)
585 len = payload_size;
586 stuffing_len = TS_PACKET_SIZE - header_len - len;
587 if (stuffing_len > 0) {
588 /* add stuffing with AFC */
589 if (buf[3] & 0x20) {
590 /* stuffing already present: increase its size */
591 afc_len = buf[4] + 1;
592 memmove(buf + 4 + afc_len + stuffing_len,
593 buf + 4 + afc_len,
594 header_len - (4 + afc_len));
595 buf[4] += stuffing_len;
596 memset(buf + 4 + afc_len, 0xff, stuffing_len);
597 } else {
598 /* add stuffing */
599 memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4);
600 buf[3] |= 0x20;
601 buf[4] = stuffing_len - 1;
602 if (stuffing_len >= 2) {
603 buf[5] = 0x00;
604 memset(buf + 6, 0xff, stuffing_len - 2);
605 }
606 }
607 }
608 memcpy(buf + TS_PACKET_SIZE - len, payload, len);
609 payload += len;
610 payload_size -= len;
611 put_buffer(&s->pb, buf, TS_PACKET_SIZE);
612 }
613 put_flush_packet(&s->pb);
614 }
615
616 static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
617 {
618 AVStream *st = s->streams[pkt->stream_index];
619 int size= pkt->size;
620 uint8_t *buf= pkt->data;
621 MpegTSWriteStream *ts_st = st->priv_data;
622 int len, max_payload_size;
623
624 if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
625 /* for subtitle, a single PES packet must be generated */
626 mpegts_write_pes(s, st, buf, size, pkt->pts, AV_NOPTS_VALUE);
627 return 0;
628 }
629
630 max_payload_size = DEFAULT_PES_PAYLOAD_SIZE;
631 while (size > 0) {
632 len = max_payload_size - ts_st->payload_index;
633 if (len > size)
634 len = size;
635 memcpy(ts_st->payload + ts_st->payload_index, buf, len);
636 buf += len;
637 size -= len;
638 ts_st->payload_index += len;
639 if (ts_st->payload_pts == AV_NOPTS_VALUE)
640 ts_st->payload_pts = pkt->pts;
641 if (ts_st->payload_dts == AV_NOPTS_VALUE)
642 ts_st->payload_dts = pkt->dts;
643 if (ts_st->payload_index >= max_payload_size) {
644 mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
645 ts_st->payload_pts, ts_st->payload_dts);
646 ts_st->payload_pts = AV_NOPTS_VALUE;
647 ts_st->payload_dts = AV_NOPTS_VALUE;
648 ts_st->payload_index = 0;
649 }
650 }
651 return 0;
652 }
653
654 static int mpegts_write_end(AVFormatContext *s)
655 {
656 MpegTSWrite *ts = s->priv_data;
657 MpegTSWriteStream *ts_st;
658 MpegTSService *service;
659 AVStream *st;
660 int i;
661
662 /* flush current packets */
663 for(i = 0; i < s->nb_streams; i++) {
664 st = s->streams[i];
665 ts_st = st->priv_data;
666 if (ts_st->payload_index > 0) {
667 mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
668 ts_st->payload_pts, ts_st->payload_dts);
669 }
670 }
671 put_flush_packet(&s->pb);
672
673 for(i = 0; i < ts->nb_services; i++) {
674 service = ts->services[i];
675 av_freep(&service->provider_name);
676 av_freep(&service->name);
677 av_free(service);
678 }
679 av_free(ts->services);
680
681 return 0;
682 }
683
684 AVOutputFormat mpegts_muxer = {
685 "mpegts",
686 "MPEG2 transport stream format",
687 "video/x-mpegts",
688 "ts",
689 sizeof(MpegTSWrite),
690 CODEC_ID_MP2,
691 CODEC_ID_MPEG2VIDEO,
692 mpegts_write_header,
693 mpegts_write_packet,
694 mpegts_write_end,
695 };