You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

624 lines
20KB

  1. /*
  2. * Ogg muxer
  3. * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at free dot fr>
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "libavutil/crc.h"
  22. #include "libavutil/mathematics.h"
  23. #include "libavutil/opt.h"
  24. #include "libavutil/random_seed.h"
  25. #include "libavcodec/xiph.h"
  26. #include "libavcodec/bytestream.h"
  27. #include "libavcodec/flac.h"
  28. #include "avformat.h"
  29. #include "avio_internal.h"
  30. #include "internal.h"
  31. #include "vorbiscomment.h"
  32. #define MAX_PAGE_SIZE 65025
  33. typedef struct {
  34. int64_t start_granule;
  35. int64_t granule;
  36. int stream_index;
  37. uint8_t flags;
  38. uint8_t segments_count;
  39. uint8_t segments[255];
  40. uint8_t data[MAX_PAGE_SIZE];
  41. uint16_t size;
  42. } OGGPage;
  43. typedef struct {
  44. unsigned page_counter;
  45. uint8_t *header[3];
  46. int header_len[3];
  47. /** for theora granule */
  48. int kfgshift;
  49. int64_t last_kf_pts;
  50. int vrev;
  51. int eos;
  52. unsigned page_count; ///< number of page buffered
  53. OGGPage page; ///< current page
  54. unsigned serial_num; ///< serial number
  55. int64_t last_granule; ///< last packet granule
  56. } OGGStreamContext;
  57. typedef struct OGGPageList {
  58. OGGPage page;
  59. struct OGGPageList *next;
  60. } OGGPageList;
  61. typedef struct {
  62. const AVClass *class;
  63. OGGPageList *page_list;
  64. int pref_size; ///< preferred page size (0 => fill all segments)
  65. int64_t pref_duration; ///< preferred page duration (0 => fill all segments)
  66. } OGGContext;
  67. #define OFFSET(x) offsetof(OGGContext, x)
  68. #define PARAM AV_OPT_FLAG_ENCODING_PARAM
  69. static const AVOption options[] = {
  70. { "pagesize", "preferred page size in bytes (deprecated)",
  71. OFFSET(pref_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_PAGE_SIZE, PARAM },
  72. { "page_duration", "preferred page duration, in microseconds",
  73. OFFSET(pref_duration), AV_OPT_TYPE_INT, { .i64 = 1000000 }, 0, INT64_MAX, PARAM },
  74. { NULL },
  75. };
  76. static const AVClass ogg_muxer_class = {
  77. .class_name = "Ogg muxer",
  78. .item_name = av_default_item_name,
  79. .option = options,
  80. .version = LIBAVUTIL_VERSION_INT,
  81. };
  82. static void ogg_update_checksum(AVFormatContext *s, AVIOContext *pb, int64_t crc_offset)
  83. {
  84. int64_t pos = avio_tell(pb);
  85. uint32_t checksum = ffio_get_checksum(pb);
  86. avio_seek(pb, crc_offset, SEEK_SET);
  87. avio_wb32(pb, checksum);
  88. avio_seek(pb, pos, SEEK_SET);
  89. }
  90. static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
  91. {
  92. OGGStreamContext *oggstream = s->streams[page->stream_index]->priv_data;
  93. AVIOContext *pb;
  94. int64_t crc_offset;
  95. int ret, size;
  96. uint8_t *buf;
  97. ret = avio_open_dyn_buf(&pb);
  98. if (ret < 0)
  99. return ret;
  100. ffio_init_checksum(pb, ff_crc04C11DB7_update, 0);
  101. ffio_wfourcc(pb, "OggS");
  102. avio_w8(pb, 0);
  103. avio_w8(pb, page->flags | extra_flags);
  104. avio_wl64(pb, page->granule);
  105. avio_wl32(pb, oggstream->serial_num);
  106. avio_wl32(pb, oggstream->page_counter++);
  107. crc_offset = avio_tell(pb);
  108. avio_wl32(pb, 0); // crc
  109. avio_w8(pb, page->segments_count);
  110. avio_write(pb, page->segments, page->segments_count);
  111. avio_write(pb, page->data, page->size);
  112. ogg_update_checksum(s, pb, crc_offset);
  113. avio_flush(pb);
  114. size = avio_close_dyn_buf(pb, &buf);
  115. if (size < 0)
  116. return size;
  117. avio_write(s->pb, buf, size);
  118. avio_flush(s->pb);
  119. av_free(buf);
  120. oggstream->page_count--;
  121. return 0;
  122. }
  123. static int64_t ogg_granule_to_timestamp(OGGStreamContext *oggstream, int64_t granule)
  124. {
  125. if (oggstream->kfgshift)
  126. return (granule>>oggstream->kfgshift) +
  127. (granule & ((1<<oggstream->kfgshift)-1));
  128. else
  129. return granule;
  130. }
  131. static int ogg_compare_granule(AVFormatContext *s, OGGPage *next, OGGPage *page)
  132. {
  133. AVStream *st2 = s->streams[next->stream_index];
  134. AVStream *st = s->streams[page->stream_index];
  135. int64_t next_granule, cur_granule;
  136. if (next->granule == -1 || page->granule == -1)
  137. return 0;
  138. next_granule = av_rescale_q(ogg_granule_to_timestamp(st2->priv_data, next->granule),
  139. st2->time_base, AV_TIME_BASE_Q);
  140. cur_granule = av_rescale_q(ogg_granule_to_timestamp(st->priv_data, page->granule),
  141. st ->time_base, AV_TIME_BASE_Q);
  142. return next_granule > cur_granule;
  143. }
  144. static int ogg_reset_cur_page(OGGStreamContext *oggstream)
  145. {
  146. oggstream->page.granule = -1;
  147. oggstream->page.flags = 0;
  148. oggstream->page.segments_count = 0;
  149. oggstream->page.size = 0;
  150. return 0;
  151. }
  152. static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream)
  153. {
  154. OGGContext *ogg = s->priv_data;
  155. OGGPageList **p = &ogg->page_list;
  156. OGGPageList *l = av_mallocz(sizeof(*l));
  157. if (!l)
  158. return AVERROR(ENOMEM);
  159. l->page = oggstream->page;
  160. oggstream->page.start_granule = oggstream->page.granule;
  161. oggstream->page_count++;
  162. ogg_reset_cur_page(oggstream);
  163. while (*p) {
  164. if (ogg_compare_granule(s, &(*p)->page, &l->page))
  165. break;
  166. p = &(*p)->next;
  167. }
  168. l->next = *p;
  169. *p = l;
  170. return 0;
  171. }
  172. static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
  173. uint8_t *data, unsigned size, int64_t granule,
  174. int header)
  175. {
  176. OGGStreamContext *oggstream = st->priv_data;
  177. OGGContext *ogg = s->priv_data;
  178. int total_segments = size / 255 + 1;
  179. uint8_t *p = data;
  180. int i, segments, len, flush = 0;
  181. // Handles VFR by flushing page because this frame needs to have a timestamp
  182. if (st->codec->codec_id == AV_CODEC_ID_THEORA && !header &&
  183. ogg_granule_to_timestamp(oggstream, granule) >
  184. ogg_granule_to_timestamp(oggstream, oggstream->last_granule) + 1) {
  185. if (oggstream->page.granule != -1)
  186. ogg_buffer_page(s, oggstream);
  187. flush = 1;
  188. }
  189. // avoid a continued page
  190. if (!header && oggstream->page.size > 0 &&
  191. MAX_PAGE_SIZE - oggstream->page.size < size) {
  192. ogg_buffer_page(s, oggstream);
  193. }
  194. for (i = 0; i < total_segments; ) {
  195. OGGPage *page = &oggstream->page;
  196. segments = FFMIN(total_segments - i, 255 - page->segments_count);
  197. if (i && !page->segments_count)
  198. page->flags |= 1; // continued packet
  199. memset(page->segments+page->segments_count, 255, segments - 1);
  200. page->segments_count += segments - 1;
  201. len = FFMIN(size, segments*255);
  202. page->segments[page->segments_count++] = len - (segments-1)*255;
  203. memcpy(page->data+page->size, p, len);
  204. p += len;
  205. size -= len;
  206. i += segments;
  207. page->size += len;
  208. if (i == total_segments)
  209. page->granule = granule;
  210. if (!header) {
  211. AVStream *st = s->streams[page->stream_index];
  212. int64_t start = av_rescale_q(page->start_granule, st->time_base,
  213. AV_TIME_BASE_Q);
  214. int64_t next = av_rescale_q(page->granule, st->time_base,
  215. AV_TIME_BASE_Q);
  216. if (page->segments_count == 255 ||
  217. (ogg->pref_size > 0 && page->size >= ogg->pref_size) ||
  218. (ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
  219. ogg_buffer_page(s, oggstream);
  220. }
  221. }
  222. }
  223. if (flush && oggstream->page.granule != -1)
  224. ogg_buffer_page(s, oggstream);
  225. return 0;
  226. }
  227. static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
  228. int *header_len, AVDictionary **m, int framing_bit)
  229. {
  230. const char *vendor = bitexact ? "Libav" : LIBAVFORMAT_IDENT;
  231. int size;
  232. uint8_t *p, *p0;
  233. unsigned int count;
  234. ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
  235. size = offset + ff_vorbiscomment_length(*m, vendor, &count) + framing_bit;
  236. p = av_mallocz(size);
  237. if (!p)
  238. return NULL;
  239. p0 = p;
  240. p += offset;
  241. ff_vorbiscomment_write(&p, m, vendor, count);
  242. if (framing_bit)
  243. bytestream_put_byte(&p, 1);
  244. *header_len = size;
  245. return p0;
  246. }
  247. static int ogg_build_flac_headers(AVCodecContext *avctx,
  248. OGGStreamContext *oggstream, int bitexact,
  249. AVDictionary **m)
  250. {
  251. enum FLACExtradataFormat format;
  252. uint8_t *streaminfo;
  253. uint8_t *p;
  254. if (!avpriv_flac_is_extradata_valid(avctx, &format, &streaminfo))
  255. return -1;
  256. // first packet: STREAMINFO
  257. oggstream->header_len[0] = 51;
  258. oggstream->header[0] = av_mallocz(51); // per ogg flac specs
  259. p = oggstream->header[0];
  260. if (!p)
  261. return AVERROR(ENOMEM);
  262. bytestream_put_byte(&p, 0x7F);
  263. bytestream_put_buffer(&p, "FLAC", 4);
  264. bytestream_put_byte(&p, 1); // major version
  265. bytestream_put_byte(&p, 0); // minor version
  266. bytestream_put_be16(&p, 1); // headers packets without this one
  267. bytestream_put_buffer(&p, "fLaC", 4);
  268. bytestream_put_byte(&p, 0x00); // streaminfo
  269. bytestream_put_be24(&p, 34);
  270. bytestream_put_buffer(&p, streaminfo, FLAC_STREAMINFO_SIZE);
  271. // second packet: VorbisComment
  272. p = ogg_write_vorbiscomment(4, bitexact, &oggstream->header_len[1], m, 0);
  273. if (!p)
  274. return AVERROR(ENOMEM);
  275. oggstream->header[1] = p;
  276. bytestream_put_byte(&p, 0x84); // last metadata block and vorbis comment
  277. bytestream_put_be24(&p, oggstream->header_len[1] - 4);
  278. return 0;
  279. }
  280. #define SPEEX_HEADER_SIZE 80
  281. static int ogg_build_speex_headers(AVCodecContext *avctx,
  282. OGGStreamContext *oggstream, int bitexact,
  283. AVDictionary **m)
  284. {
  285. uint8_t *p;
  286. if (avctx->extradata_size < SPEEX_HEADER_SIZE)
  287. return -1;
  288. // first packet: Speex header
  289. p = av_mallocz(SPEEX_HEADER_SIZE);
  290. if (!p)
  291. return AVERROR(ENOMEM);
  292. oggstream->header[0] = p;
  293. oggstream->header_len[0] = SPEEX_HEADER_SIZE;
  294. bytestream_put_buffer(&p, avctx->extradata, SPEEX_HEADER_SIZE);
  295. AV_WL32(&oggstream->header[0][68], 0); // set extra_headers to 0
  296. // second packet: VorbisComment
  297. p = ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m, 0);
  298. if (!p)
  299. return AVERROR(ENOMEM);
  300. oggstream->header[1] = p;
  301. return 0;
  302. }
  303. #define OPUS_HEADER_SIZE 19
  304. static int ogg_build_opus_headers(AVCodecContext *avctx,
  305. OGGStreamContext *oggstream, int bitexact,
  306. AVDictionary **m)
  307. {
  308. uint8_t *p;
  309. if (avctx->extradata_size < OPUS_HEADER_SIZE)
  310. return -1;
  311. /* first packet: Opus header */
  312. p = av_mallocz(avctx->extradata_size);
  313. if (!p)
  314. return AVERROR(ENOMEM);
  315. oggstream->header[0] = p;
  316. oggstream->header_len[0] = avctx->extradata_size;
  317. bytestream_put_buffer(&p, avctx->extradata, avctx->extradata_size);
  318. /* second packet: VorbisComment */
  319. p = ogg_write_vorbiscomment(8, bitexact, &oggstream->header_len[1], m, 0);
  320. if (!p)
  321. return AVERROR(ENOMEM);
  322. oggstream->header[1] = p;
  323. bytestream_put_buffer(&p, "OpusTags", 8);
  324. return 0;
  325. }
  326. static int ogg_write_header(AVFormatContext *s)
  327. {
  328. OGGContext *ogg = s->priv_data;
  329. OGGStreamContext *oggstream;
  330. int i, j;
  331. if (ogg->pref_size)
  332. av_log(s, AV_LOG_WARNING, "The pagesize option is deprecated\n");
  333. for (i = 0; i < s->nb_streams; i++) {
  334. AVStream *st = s->streams[i];
  335. unsigned serial_num = i;
  336. if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
  337. if (st->codec->codec_id == AV_CODEC_ID_OPUS)
  338. /* Opus requires a fixed 48kHz clock */
  339. avpriv_set_pts_info(st, 64, 1, 48000);
  340. else
  341. avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
  342. else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
  343. avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den);
  344. if (st->codec->codec_id != AV_CODEC_ID_VORBIS &&
  345. st->codec->codec_id != AV_CODEC_ID_THEORA &&
  346. st->codec->codec_id != AV_CODEC_ID_SPEEX &&
  347. st->codec->codec_id != AV_CODEC_ID_FLAC &&
  348. st->codec->codec_id != AV_CODEC_ID_OPUS) {
  349. av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i);
  350. return -1;
  351. }
  352. if (!st->codec->extradata || !st->codec->extradata_size) {
  353. av_log(s, AV_LOG_ERROR, "No extradata present\n");
  354. return -1;
  355. }
  356. oggstream = av_mallocz(sizeof(*oggstream));
  357. oggstream->page.stream_index = i;
  358. if (!(st->codec->flags & CODEC_FLAG_BITEXACT))
  359. do {
  360. serial_num = av_get_random_seed();
  361. for (j = 0; j < i; j++) {
  362. OGGStreamContext *sc = s->streams[j]->priv_data;
  363. if (serial_num == sc->serial_num)
  364. break;
  365. }
  366. } while (j < i);
  367. oggstream->serial_num = serial_num;
  368. st->priv_data = oggstream;
  369. if (st->codec->codec_id == AV_CODEC_ID_FLAC) {
  370. int err = ogg_build_flac_headers(st->codec, oggstream,
  371. st->codec->flags & CODEC_FLAG_BITEXACT,
  372. &s->metadata);
  373. if (err) {
  374. av_log(s, AV_LOG_ERROR, "Error writing FLAC headers\n");
  375. av_freep(&st->priv_data);
  376. return err;
  377. }
  378. } else if (st->codec->codec_id == AV_CODEC_ID_SPEEX) {
  379. int err = ogg_build_speex_headers(st->codec, oggstream,
  380. st->codec->flags & CODEC_FLAG_BITEXACT,
  381. &s->metadata);
  382. if (err) {
  383. av_log(s, AV_LOG_ERROR, "Error writing Speex headers\n");
  384. av_freep(&st->priv_data);
  385. return err;
  386. }
  387. } else if (st->codec->codec_id == AV_CODEC_ID_OPUS) {
  388. int err = ogg_build_opus_headers(st->codec, oggstream,
  389. st->codec->flags & CODEC_FLAG_BITEXACT,
  390. &s->metadata);
  391. if (err) {
  392. av_log(s, AV_LOG_ERROR, "Error writing Opus headers\n");
  393. av_freep(&st->priv_data);
  394. return err;
  395. }
  396. } else {
  397. uint8_t *p;
  398. const char *cstr = st->codec->codec_id == AV_CODEC_ID_VORBIS ? "vorbis" : "theora";
  399. int header_type = st->codec->codec_id == AV_CODEC_ID_VORBIS ? 3 : 0x81;
  400. int framing_bit = st->codec->codec_id == AV_CODEC_ID_VORBIS ? 1 : 0;
  401. if (avpriv_split_xiph_headers(st->codec->extradata, st->codec->extradata_size,
  402. st->codec->codec_id == AV_CODEC_ID_VORBIS ? 30 : 42,
  403. oggstream->header, oggstream->header_len) < 0) {
  404. av_log(s, AV_LOG_ERROR, "Extradata corrupted\n");
  405. av_freep(&st->priv_data);
  406. return -1;
  407. }
  408. p = ogg_write_vorbiscomment(7, st->codec->flags & CODEC_FLAG_BITEXACT,
  409. &oggstream->header_len[1], &s->metadata,
  410. framing_bit);
  411. oggstream->header[1] = p;
  412. if (!p)
  413. return AVERROR(ENOMEM);
  414. bytestream_put_byte(&p, header_type);
  415. bytestream_put_buffer(&p, cstr, 6);
  416. if (st->codec->codec_id == AV_CODEC_ID_THEORA) {
  417. /** KFGSHIFT is the width of the less significant section of the granule position
  418. The less significant section is the frame count since the last keyframe */
  419. oggstream->kfgshift = ((oggstream->header[0][40]&3)<<3)|(oggstream->header[0][41]>>5);
  420. oggstream->vrev = oggstream->header[0][9];
  421. av_log(s, AV_LOG_DEBUG, "theora kfgshift %d, vrev %d\n",
  422. oggstream->kfgshift, oggstream->vrev);
  423. }
  424. }
  425. }
  426. for (j = 0; j < s->nb_streams; j++) {
  427. OGGStreamContext *oggstream = s->streams[j]->priv_data;
  428. ogg_buffer_data(s, s->streams[j], oggstream->header[0],
  429. oggstream->header_len[0], 0, 1);
  430. oggstream->page.flags |= 2; // bos
  431. ogg_buffer_page(s, oggstream);
  432. }
  433. for (j = 0; j < s->nb_streams; j++) {
  434. AVStream *st = s->streams[j];
  435. OGGStreamContext *oggstream = st->priv_data;
  436. for (i = 1; i < 3; i++) {
  437. if (oggstream && oggstream->header_len[i])
  438. ogg_buffer_data(s, st, oggstream->header[i],
  439. oggstream->header_len[i], 0, 1);
  440. }
  441. ogg_buffer_page(s, oggstream);
  442. }
  443. oggstream->page.start_granule = AV_NOPTS_VALUE;
  444. return 0;
  445. }
  446. static void ogg_write_pages(AVFormatContext *s, int flush)
  447. {
  448. OGGContext *ogg = s->priv_data;
  449. OGGPageList *next, *p;
  450. if (!ogg->page_list)
  451. return;
  452. for (p = ogg->page_list; p; ) {
  453. OGGStreamContext *oggstream =
  454. s->streams[p->page.stream_index]->priv_data;
  455. if (oggstream->page_count < 2 && !flush)
  456. break;
  457. ogg_write_page(s, &p->page,
  458. flush && oggstream->page_count == 1 ? 4 : 0); // eos
  459. next = p->next;
  460. av_freep(&p);
  461. p = next;
  462. }
  463. ogg->page_list = p;
  464. }
  465. static int ogg_write_packet(AVFormatContext *s, AVPacket *pkt)
  466. {
  467. AVStream *st = s->streams[pkt->stream_index];
  468. OGGStreamContext *oggstream = st->priv_data;
  469. int ret;
  470. int64_t granule;
  471. if (st->codec->codec_id == AV_CODEC_ID_THEORA) {
  472. int64_t pts = oggstream->vrev < 1 ? pkt->pts : pkt->pts + pkt->duration;
  473. int pframe_count;
  474. if (pkt->flags & AV_PKT_FLAG_KEY)
  475. oggstream->last_kf_pts = pts;
  476. pframe_count = pts - oggstream->last_kf_pts;
  477. // prevent frame count from overflow if key frame flag is not set
  478. if (pframe_count >= (1<<oggstream->kfgshift)) {
  479. oggstream->last_kf_pts += pframe_count;
  480. pframe_count = 0;
  481. }
  482. granule = (oggstream->last_kf_pts<<oggstream->kfgshift) | pframe_count;
  483. } else if (st->codec->codec_id == AV_CODEC_ID_OPUS)
  484. granule = pkt->pts + pkt->duration + av_rescale_q(st->codec->delay, (AVRational){ 1, st->codec->sample_rate }, st->time_base);
  485. else
  486. granule = pkt->pts + pkt->duration;
  487. if (oggstream->page.start_granule == AV_NOPTS_VALUE)
  488. oggstream->page.start_granule = pkt->pts;
  489. ret = ogg_buffer_data(s, st, pkt->data, pkt->size, granule, 0);
  490. if (ret < 0)
  491. return ret;
  492. ogg_write_pages(s, 0);
  493. oggstream->last_granule = granule;
  494. return 0;
  495. }
  496. static int ogg_write_trailer(AVFormatContext *s)
  497. {
  498. int i;
  499. /* flush current page if needed */
  500. for (i = 0; i < s->nb_streams; i++) {
  501. OGGStreamContext *oggstream = s->streams[i]->priv_data;
  502. if (oggstream->page.size > 0)
  503. ogg_buffer_page(s, oggstream);
  504. }
  505. ogg_write_pages(s, 1);
  506. for (i = 0; i < s->nb_streams; i++) {
  507. AVStream *st = s->streams[i];
  508. OGGStreamContext *oggstream = st->priv_data;
  509. if (st->codec->codec_id == AV_CODEC_ID_FLAC ||
  510. st->codec->codec_id == AV_CODEC_ID_SPEEX ||
  511. st->codec->codec_id == AV_CODEC_ID_OPUS) {
  512. av_free(oggstream->header[0]);
  513. }
  514. av_freep(&oggstream->header[1]);
  515. av_freep(&st->priv_data);
  516. }
  517. return 0;
  518. }
  519. AVOutputFormat ff_ogg_muxer = {
  520. .name = "ogg",
  521. .long_name = NULL_IF_CONFIG_SMALL("Ogg"),
  522. .mime_type = "application/ogg",
  523. .extensions = "ogg,ogv,spx,opus",
  524. .priv_data_size = sizeof(OGGContext),
  525. .audio_codec = AV_CODEC_ID_FLAC,
  526. .video_codec = AV_CODEC_ID_THEORA,
  527. .write_header = ogg_write_header,
  528. .write_packet = ogg_write_packet,
  529. .write_trailer = ogg_write_trailer,
  530. .priv_class = &ogg_muxer_class,
  531. };