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 00042 typedef struct MOVIentry { 00043 unsigned int size; 00044 uint64_t pos; 00045 unsigned int samplesInChunk; 00046 unsigned int chunkNum; 00047 unsigned int entries; 00048 int cts; 00049 int64_t dts; 00050 #define MOV_SYNC_SAMPLE 0x0001 00051 #define MOV_PARTIAL_SYNC_SAMPLE 0x0002 00052 uint32_t flags; 00053 uint8_t *data; 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 MOVIndex { 00071 int mode; 00072 int entry; 00073 unsigned timescale; 00074 uint64_t time; 00075 int64_t trackDuration; 00076 long sampleCount; 00077 long sampleSize; 00078 long chunkCount; 00079 int hasKeyframes; 00080 #define MOV_TRACK_CTTS 0x0001 00081 #define MOV_TRACK_STPS 0x0002 00082 uint32_t flags; 00083 int language; 00084 int trackID; 00085 int tag; 00086 AVCodecContext *enc; 00087 00088 int vosLen; 00089 uint8_t *vosData; 00090 int cluster_write_index; 00091 MOVIentry *cluster; 00092 int audio_vbr; 00093 int height; 00094 uint32_t tref_tag; 00095 int tref_id; 00096 00097 int hint_track; 00098 int src_track; 00099 AVFormatContext *rtp_ctx; 00100 uint32_t prev_rtp_ts; 00101 int64_t cur_rtp_ts_unwrapped; 00102 uint32_t max_packet_size; 00103 int64_t base_data_offset_pos; 00104 00105 HintSampleQueue sample_queue; 00106 } MOVTrack; 00107 00108 typedef struct MOVMuxContext { 00109 const AVClass *av_class; 00110 int mode; 00111 int64_t time; 00112 int nb_streams; 00113 int chapter_track; 00114 int64_t mdat_pos; 00115 uint64_t mdat_size; 00116 MOVTrack *tracks; 00117 int fragments; 00118 int frag_seq_num; 00119 00120 int flags; 00121 int rtp_flags; 00122 int reserved_moov_size; 00123 int64_t reserved_moov_pos; 00124 int max_fragment_duration; 00125 int max_fragment_size; 00126 } MOVMuxContext; 00127 00128 #define FF_MOV_FLAG_RTP_HINT 1 00129 00130 int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); 00131 00132 int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index); 00133 int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, 00134 int track_index, int sample); 00135 void ff_mov_close_hinting(MOVTrack *track); 00136 00137 #endif /* AVFORMAT_MOVENC_H */