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 entries; 00047 int cts; 00048 int64_t dts; 00049 #define MOV_SYNC_SAMPLE 0x0001 00050 #define MOV_PARTIAL_SYNC_SAMPLE 0x0002 00051 uint32_t flags; 00052 } MOVIentry; 00053 00054 typedef struct HintSample { 00055 uint8_t *data; 00056 int size; 00057 int sample_number; 00058 int offset; 00059 int own_data; 00060 } HintSample; 00061 00062 typedef struct { 00063 int size; 00064 int len; 00065 HintSample *samples; 00066 } HintSampleQueue; 00067 00068 typedef struct MOVIndex { 00069 int mode; 00070 int entry; 00071 unsigned timescale; 00072 uint64_t time; 00073 int64_t trackDuration; 00074 long sampleCount; 00075 long sampleSize; 00076 int hasKeyframes; 00077 #define MOV_TRACK_CTTS 0x0001 00078 #define MOV_TRACK_STPS 0x0002 00079 uint32_t flags; 00080 int language; 00081 int trackID; 00082 int tag; 00083 AVCodecContext *enc; 00084 00085 int vosLen; 00086 uint8_t *vosData; 00087 MOVIentry *cluster; 00088 int audio_vbr; 00089 int height; 00090 uint32_t tref_tag; 00091 int tref_id; 00092 00093 int hint_track; 00094 int src_track; 00095 AVFormatContext *rtp_ctx; 00096 uint32_t prev_rtp_ts; 00097 int64_t cur_rtp_ts_unwrapped; 00098 uint32_t max_packet_size; 00099 00100 HintSampleQueue sample_queue; 00101 } MOVTrack; 00102 00103 typedef struct MOVMuxContext { 00104 const AVClass *av_class; 00105 int mode; 00106 int64_t time; 00107 int nb_streams; 00108 int chapter_track; 00109 int64_t mdat_pos; 00110 uint64_t mdat_size; 00111 MOVTrack *tracks; 00112 00113 int flags; 00114 int rtp_flags; 00115 } MOVMuxContext; 00116 00117 #define FF_MOV_FLAG_RTP_HINT 1 00118 00119 int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); 00120 00121 int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index); 00122 int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, 00123 int track_index, int sample); 00124 void ff_mov_close_hinting(MOVTrack *track); 00125 00126 #endif /* AVFORMAT_MOVENC_H */