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.

180 lines
5.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. #define MODE_ISM 0x40
  37. typedef struct MOVIentry {
  38. uint64_t pos;
  39. int64_t dts;
  40. unsigned int size;
  41. unsigned int samples_in_chunk;
  42. unsigned int chunkNum; ///< Chunk number if the current entry is a chunk start otherwise 0
  43. unsigned int entries;
  44. int cts;
  45. #define MOV_SYNC_SAMPLE 0x0001
  46. #define MOV_PARTIAL_SYNC_SAMPLE 0x0002
  47. uint32_t flags;
  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 {
  62. int64_t offset;
  63. int64_t time;
  64. int64_t duration;
  65. int64_t tfrf_offset;
  66. } MOVFragmentInfo;
  67. typedef struct MOVIndex {
  68. int mode;
  69. int entry;
  70. unsigned timescale;
  71. uint64_t time;
  72. int64_t track_duration;
  73. long sample_count;
  74. long sample_size;
  75. long chunkCount;
  76. int has_keyframes;
  77. #define MOV_TRACK_CTTS 0x0001
  78. #define MOV_TRACK_STPS 0x0002
  79. uint32_t flags;
  80. int language;
  81. int track_id;
  82. int tag; ///< stsd fourcc
  83. AVCodecContext *enc;
  84. int vos_len;
  85. uint8_t *vos_data;
  86. MOVIentry *cluster;
  87. int audio_vbr;
  88. int height; ///< active picture (w/o VBI) height for D-10/IMX
  89. uint32_t tref_tag;
  90. int tref_id; ///< trackID of the referenced track
  91. int64_t start_dts;
  92. int hint_track; ///< the track that hints this track, -1 if no hint track is set
  93. int src_track; ///< the track that this hint track describes
  94. AVFormatContext *rtp_ctx; ///< the format context for the hinting rtp muxer
  95. uint32_t prev_rtp_ts;
  96. int64_t cur_rtp_ts_unwrapped;
  97. uint32_t max_packet_size;
  98. int64_t default_duration;
  99. uint32_t default_sample_flags;
  100. uint32_t default_size;
  101. HintSampleQueue sample_queue;
  102. AVIOContext *mdat_buf;
  103. int64_t moof_size_offset;
  104. int64_t data_offset;
  105. int64_t frag_start;
  106. int64_t tfrf_offset;
  107. int nb_frag_info;
  108. MOVFragmentInfo *frag_info;
  109. struct {
  110. int64_t struct_offset;
  111. int first_packet_seq;
  112. int first_packet_entry;
  113. int packet_seq;
  114. int packet_entry;
  115. int slices;
  116. } vc1_info;
  117. } MOVTrack;
  118. typedef struct MOVMuxContext {
  119. const AVClass *av_class;
  120. int mode;
  121. int64_t time;
  122. int nb_streams;
  123. int chapter_track; ///< qt chapter track number
  124. int64_t mdat_pos;
  125. uint64_t mdat_size;
  126. MOVTrack *tracks;
  127. int flags;
  128. int rtp_flags;
  129. int reserved_moov_size;
  130. int64_t reserved_moov_pos;
  131. int iods_skip;
  132. int iods_video_profile;
  133. int iods_audio_profile;
  134. int fragments;
  135. int max_fragment_duration;
  136. int min_fragment_duration;
  137. int max_fragment_size;
  138. int ism_lookahead;
  139. AVIOContext *mdat_buf;
  140. } MOVMuxContext;
  141. #define FF_MOV_FLAG_RTP_HINT 1
  142. #define FF_MOV_FLAG_FRAGMENT 2
  143. #define FF_MOV_FLAG_EMPTY_MOOV 4
  144. #define FF_MOV_FLAG_FRAG_KEYFRAME 8
  145. #define FF_MOV_FLAG_SEPARATE_MOOF 16
  146. #define FF_MOV_FLAG_FRAG_CUSTOM 32
  147. #define FF_MOV_FLAG_ISML 64
  148. int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
  149. int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index);
  150. int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt,
  151. int track_index, int sample,
  152. uint8_t *sample_data, int sample_size);
  153. void ff_mov_close_hinting(MOVTrack *track);
  154. #endif /* AVFORMAT_MOVENC_H */