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.

138 lines
4.0KB

  1. /*
  2. * MOV, 3GP, MP4 muxer
  3. * Copyright (c) 2003 Thomas Raivio
  4. * Copyright (c) 2004 Gildas Bazin <gbazin at videolan dot org>
  5. * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #ifndef AVFORMAT_MOVENC_H
  24. #define AVFORMAT_MOVENC_H
  25. #include "avformat.h"
  26. #define MOV_INDEX_CLUSTER_SIZE 16384
  27. #define MOV_TIMESCALE 1000
  28. #define RTP_MAX_PACKET_SIZE 1450
  29. #define MODE_MP4 0x01
  30. #define MODE_MOV 0x02
  31. #define MODE_3GP 0x04
  32. #define MODE_PSP 0x08 // example working PSP command line:
  33. // ffmpeg -i testinput.avi -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 M4V00001.MP4
  34. #define MODE_3G2 0x10
  35. #define MODE_IPOD 0x20
  36. typedef struct MOVIentry {
  37. unsigned int size;
  38. uint64_t pos;
  39. unsigned int samplesInChunk;
  40. unsigned int chunkNum; ///< Chunk number if the current entry is a chunk start otherwise 0
  41. unsigned int entries;
  42. int cts;
  43. int64_t dts;
  44. #define MOV_SYNC_SAMPLE 0x0001
  45. #define MOV_PARTIAL_SYNC_SAMPLE 0x0002
  46. uint32_t flags;
  47. uint8_t *data;
  48. } MOVIentry;
  49. typedef struct HintSample {
  50. uint8_t *data;
  51. int size;
  52. int sample_number;
  53. int offset;
  54. int own_data;
  55. } HintSample;
  56. typedef struct {
  57. int size;
  58. int len;
  59. HintSample *samples;
  60. } HintSampleQueue;
  61. typedef struct MOVIndex {
  62. int mode;
  63. int entry;
  64. unsigned timescale;
  65. uint64_t time;
  66. int64_t trackDuration;
  67. long sampleCount;
  68. long sampleSize;
  69. long chunkCount;
  70. int hasKeyframes;
  71. #define MOV_TRACK_CTTS 0x0001
  72. #define MOV_TRACK_STPS 0x0002
  73. uint32_t flags;
  74. int language;
  75. int trackID;
  76. int tag; ///< stsd fourcc
  77. AVCodecContext *enc;
  78. int vosLen;
  79. uint8_t *vosData;
  80. int cluster_write_index;
  81. MOVIentry *cluster;
  82. int audio_vbr;
  83. int height; ///< active picture (w/o VBI) height for D-10/IMX
  84. uint32_t tref_tag;
  85. int tref_id; ///< trackID of the referenced track
  86. int hint_track; ///< the track that hints this track, -1 if no hint track is set
  87. int src_track; ///< the track that this hint track describes
  88. AVFormatContext *rtp_ctx; ///< the format context for the hinting rtp muxer
  89. uint32_t prev_rtp_ts;
  90. int64_t cur_rtp_ts_unwrapped;
  91. uint32_t max_packet_size;
  92. int64_t base_data_offset_pos;
  93. HintSampleQueue sample_queue;
  94. } MOVTrack;
  95. typedef struct MOVMuxContext {
  96. const AVClass *av_class;
  97. int mode;
  98. int64_t time;
  99. int nb_streams;
  100. int chapter_track; ///< qt chapter track number
  101. int64_t mdat_pos;
  102. uint64_t mdat_size;
  103. MOVTrack *tracks;
  104. int fragments;
  105. int frag_seq_num;
  106. int flags;
  107. int rtp_flags;
  108. int reserved_moov_size;
  109. int64_t reserved_moov_pos;
  110. int max_fragment_duration;
  111. int max_fragment_size;
  112. } MOVMuxContext;
  113. #define FF_MOV_FLAG_RTP_HINT 1
  114. int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
  115. int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index);
  116. int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt,
  117. int track_index, int sample);
  118. void ff_mov_close_hinting(MOVTrack *track);
  119. #endif /* AVFORMAT_MOVENC_H */