00001 /* 00002 * MOV, 3GP, MP4 muxer 00003 * Copyright (c) 2003 Thomas Raivio 00004 * Copyright (c) 2004 Gildas Bazin <gbazin at videolan dot org> 00005 * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com> 00006 * 00007 * This file is part of FFmpeg. 00008 * 00009 * FFmpeg is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * FFmpeg is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with FFmpeg; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 */ 00023 00024 #ifndef AVFORMAT_MOVENC_H 00025 #define AVFORMAT_MOVENC_H 00026 00027 #include "avformat.h" 00028 00029 #define MOV_INDEX_CLUSTER_SIZE 16384 00030 #define MOV_TIMESCALE 1000 00031 00032 #define RTP_MAX_PACKET_SIZE 1450 00033 00034 #define MODE_MP4 0x01 00035 #define MODE_MOV 0x02 00036 #define MODE_3GP 0x04 00037 #define MODE_PSP 0x08 // example working PSP command line: 00038 // ffmpeg -i testinput.avi -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 M4V00001.MP4 00039 #define MODE_3G2 0x10 00040 #define MODE_IPOD 0x20 00041 #define MODE_ISM 0x40 00042 00043 typedef struct MOVIentry { 00044 uint64_t pos; 00045 int64_t dts; 00046 unsigned int size; 00047 unsigned int samplesInChunk; 00048 unsigned int chunkNum; 00049 unsigned int entries; 00050 int cts; 00051 #define MOV_SYNC_SAMPLE 0x0001 00052 #define MOV_PARTIAL_SYNC_SAMPLE 0x0002 00053 uint32_t flags; 00054 } MOVIentry; 00055 00056 typedef struct HintSample { 00057 uint8_t *data; 00058 int size; 00059 int sample_number; 00060 int offset; 00061 int own_data; 00062 } HintSample; 00063 00064 typedef struct { 00065 int size; 00066 int len; 00067 HintSample *samples; 00068 } HintSampleQueue; 00069 00070 typedef struct { 00071 int64_t offset; 00072 int64_t time; 00073 int64_t duration; 00074 int64_t tfrf_offset; 00075 } MOVFragmentInfo; 00076 00077 typedef struct MOVIndex { 00078 int mode; 00079 int entry; 00080 unsigned timescale; 00081 uint64_t time; 00082 int64_t trackDuration; 00083 long sampleCount; 00084 long sampleSize; 00085 long chunkCount; 00086 int hasKeyframes; 00087 #define MOV_TRACK_CTTS 0x0001 00088 #define MOV_TRACK_STPS 0x0002 00089 uint32_t flags; 00090 int language; 00091 int trackID; 00092 int tag; 00093 AVCodecContext *enc; 00094 00095 int vosLen; 00096 uint8_t *vosData; 00097 MOVIentry *cluster; 00098 int audio_vbr; 00099 int height; 00100 uint32_t tref_tag; 00101 int tref_id; 00102 int64_t start_dts; 00103 00104 int hint_track; 00105 int src_track; 00106 AVFormatContext *rtp_ctx; 00107 uint32_t prev_rtp_ts; 00108 int64_t cur_rtp_ts_unwrapped; 00109 uint32_t max_packet_size; 00110 00111 int64_t default_duration; 00112 uint32_t default_sample_flags; 00113 uint32_t default_size; 00114 00115 HintSampleQueue sample_queue; 00116 00117 AVIOContext *mdat_buf; 00118 int64_t moof_size_offset; 00119 int64_t data_offset; 00120 int64_t frag_start; 00121 int64_t tfrf_offset; 00122 00123 int nb_frag_info; 00124 MOVFragmentInfo *frag_info; 00125 } MOVTrack; 00126 00127 typedef struct MOVMuxContext { 00128 const AVClass *av_class; 00129 int mode; 00130 int64_t time; 00131 int nb_streams; 00132 int chapter_track; 00133 int64_t mdat_pos; 00134 uint64_t mdat_size; 00135 MOVTrack *tracks; 00136 00137 int flags; 00138 int rtp_flags; 00139 int reserved_moov_size; 00140 int64_t reserved_moov_pos; 00141 00142 int iods_skip; 00143 int iods_video_profile; 00144 int iods_audio_profile; 00145 00146 int fragments; 00147 int max_fragment_duration; 00148 int max_fragment_size; 00149 int ism_lookahead; 00150 } MOVMuxContext; 00151 00152 #define FF_MOV_FLAG_RTP_HINT 1 00153 #define FF_MOV_FLAG_FRAGMENT 2 00154 #define FF_MOV_FLAG_EMPTY_MOOV 4 00155 #define FF_MOV_FLAG_FRAG_KEYFRAME 8 00156 #define FF_MOV_FLAG_SEPARATE_MOOF 16 00157 #define FF_MOV_FLAG_FRAG_CUSTOM 32 00158 00159 int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); 00160 00161 int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index); 00162 int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, 00163 int track_index, int sample, 00164 uint8_t *sample_data, int sample_size); 00165 void ff_mov_close_hinting(MOVTrack *track); 00166 00167 #endif /* AVFORMAT_MOVENC_H */