FFmpeg
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
ffmpeg.h
Go to the documentation of this file.
1
/*
2
* This file is part of FFmpeg.
3
*
4
* FFmpeg is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* FFmpeg is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with FFmpeg; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
19
#ifndef FFMPEG_H
20
#define FFMPEG_H
21
22
#include "config.h"
23
24
#include <stdint.h>
25
#include <stdio.h>
26
#include <signal.h>
27
28
#if HAVE_PTHREADS
29
#include <pthread.h>
30
#endif
31
32
#include "
cmdutils.h
"
33
34
#include "
libavformat/avformat.h
"
35
#include "
libavformat/avio.h
"
36
37
#include "
libavcodec/avcodec.h
"
38
39
#include "
libavfilter/avfilter.h
"
40
#include "
libavfilter/avfiltergraph.h
"
41
42
#include "
libavutil/avutil.h
"
43
#include "
libavutil/dict.h
"
44
#include "
libavutil/fifo.h
"
45
#include "
libavutil/pixfmt.h
"
46
#include "
libavutil/rational.h
"
47
48
#include "
libswresample/swresample.h
"
49
50
#define VSYNC_AUTO -1
51
#define VSYNC_PASSTHROUGH 0
52
#define VSYNC_CFR 1
53
#define VSYNC_VFR 2
54
#define VSYNC_DROP 0xff
55
56
#define MAX_STREAMS 1024
/* arbitrary sanity check value */
57
58
/* select an input stream for an output stream */
59
typedef
struct
StreamMap
{
60
int
disabled
;
/* 1 is this mapping is disabled by a negative map */
61
int
file_index
;
62
int
stream_index
;
63
int
sync_file_index
;
64
int
sync_stream_index
;
65
char
*
linklabel
;
/* name of an output link, for mapping lavfi outputs */
66
}
StreamMap
;
67
68
typedef
struct
{
69
int
file_idx,
stream_idx
, channel_idx;
// input
70
int
ofile_idx,
ostream_idx
;
// output
71
}
AudioChannelMap
;
72
73
typedef
struct
OptionsContext
{
74
OptionGroup
*
g
;
75
76
/* input/output options */
77
int64_t
start_time
;
78
const
char
*
format
;
79
80
SpecifierOpt
*
codec_names
;
81
int
nb_codec_names
;
82
SpecifierOpt
*
audio_channels
;
83
int
nb_audio_channels
;
84
SpecifierOpt
*
audio_sample_rate
;
85
int
nb_audio_sample_rate
;
86
SpecifierOpt
*
frame_rates
;
87
int
nb_frame_rates
;
88
SpecifierOpt
*
frame_sizes
;
89
int
nb_frame_sizes
;
90
SpecifierOpt
*
frame_pix_fmts
;
91
int
nb_frame_pix_fmts
;
92
93
/* input options */
94
int64_t
input_ts_offset
;
95
int
rate_emu
;
96
97
SpecifierOpt
*
ts_scale
;
98
int
nb_ts_scale
;
99
SpecifierOpt
*
dump_attachment
;
100
int
nb_dump_attachment
;
101
102
/* output options */
103
StreamMap
*
stream_maps
;
104
int
nb_stream_maps
;
105
AudioChannelMap
*
audio_channel_maps
;
/* one info entry per -map_channel */
106
int
nb_audio_channel_maps
;
/* number of (valid) -map_channel settings */
107
int
metadata_global_manual
;
108
int
metadata_streams_manual
;
109
int
metadata_chapters_manual
;
110
const
char
**
attachments
;
111
int
nb_attachments
;
112
113
int
chapters_input_file
;
114
115
int64_t
recording_time
;
116
uint64_t
limit_filesize
;
117
float
mux_preload
;
118
float
mux_max_delay
;
119
int
shortest
;
120
121
int
video_disable
;
122
int
audio_disable
;
123
int
subtitle_disable
;
124
int
data_disable
;
125
126
/* indexed by output file stream index */
127
int
*
streamid_map
;
128
int
nb_streamid_map
;
129
130
SpecifierOpt
*
metadata
;
131
int
nb_metadata
;
132
SpecifierOpt
*
max_frames
;
133
int
nb_max_frames
;
134
SpecifierOpt
*
bitstream_filters
;
135
int
nb_bitstream_filters
;
136
SpecifierOpt
*
codec_tags
;
137
int
nb_codec_tags
;
138
SpecifierOpt
*
sample_fmts
;
139
int
nb_sample_fmts
;
140
SpecifierOpt
*
qscale
;
141
int
nb_qscale
;
142
SpecifierOpt
*
forced_key_frames
;
143
int
nb_forced_key_frames
;
144
SpecifierOpt
*
force_fps
;
145
int
nb_force_fps
;
146
SpecifierOpt
*
frame_aspect_ratios
;
147
int
nb_frame_aspect_ratios
;
148
SpecifierOpt
*
rc_overrides
;
149
int
nb_rc_overrides
;
150
SpecifierOpt
*
intra_matrices
;
151
int
nb_intra_matrices
;
152
SpecifierOpt
*
inter_matrices
;
153
int
nb_inter_matrices
;
154
SpecifierOpt
*
top_field_first
;
155
int
nb_top_field_first
;
156
SpecifierOpt
*
metadata_map
;
157
int
nb_metadata_map
;
158
SpecifierOpt
*
presets
;
159
int
nb_presets
;
160
SpecifierOpt
*
copy_initial_nonkeyframes
;
161
int
nb_copy_initial_nonkeyframes
;
162
SpecifierOpt
*
copy_prior_start
;
163
int
nb_copy_prior_start
;
164
SpecifierOpt
*
filters
;
165
int
nb_filters
;
166
SpecifierOpt
*
reinit_filters
;
167
int
nb_reinit_filters
;
168
SpecifierOpt
*
fix_sub_duration
;
169
int
nb_fix_sub_duration
;
170
SpecifierOpt
*
pass
;
171
int
nb_pass
;
172
SpecifierOpt
*
passlogfiles
;
173
int
nb_passlogfiles
;
174
}
OptionsContext
;
175
176
typedef
struct
InputFilter
{
177
AVFilterContext
*
filter
;
178
struct
InputStream
*
ist
;
179
struct
FilterGraph
*
graph
;
180
uint8_t
*
name
;
181
}
InputFilter
;
182
183
typedef
struct
OutputFilter
{
184
AVFilterContext
*
filter
;
185
struct
OutputStream
*
ost
;
186
struct
FilterGraph
*
graph
;
187
uint8_t
*
name
;
188
189
/* temporary storage until stream maps are processed */
190
AVFilterInOut
*
out_tmp
;
191
}
OutputFilter
;
192
193
typedef
struct
FilterGraph
{
194
int
index
;
195
const
char
*
graph_desc
;
196
197
AVFilterGraph
*
graph
;
198
199
InputFilter
**
inputs
;
200
int
nb_inputs
;
201
OutputFilter
**
outputs
;
202
int
nb_outputs
;
203
}
FilterGraph
;
204
205
typedef
struct
InputStream
{
206
int
file_index
;
207
AVStream
*
st
;
208
int
discard
;
/* true if stream data should be discarded */
209
int
decoding_needed
;
/* true if the packets must be decoded in 'raw_fifo' */
210
AVCodec
*
dec
;
211
AVFrame
*
decoded_frame
;
212
213
int64_t
start
;
/* time when read started */
214
/* predicted dts of the next packet read for this stream or (when there are
215
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
216
int64_t
next_dts
;
217
int64_t
dts
;
///< dts of the last packet read for this stream (in AV_TIME_BASE units)
218
219
int64_t
next_pts
;
///< synthetic pts for the next decode frame (in AV_TIME_BASE units)
220
int64_t
pts
;
///< current pts of the decoded frame (in AV_TIME_BASE units)
221
int
wrap_correction_done
;
222
223
int64_t
filter_in_rescale_delta_last
;
224
225
double
ts_scale
;
226
int
is_start
;
/* is 1 at the start and after a discontinuity */
227
int
saw_first_ts
;
228
int
showed_multi_packet_warning
;
229
AVDictionary
*
opts
;
230
AVRational
framerate
;
/* framerate forced with -r */
231
int
top_field_first
;
232
233
int
resample_height
;
234
int
resample_width
;
235
int
resample_pix_fmt
;
236
237
int
resample_sample_fmt
;
238
int
resample_sample_rate
;
239
int
resample_channels
;
240
uint64_t
resample_channel_layout
;
241
242
int
fix_sub_duration
;
243
struct
{
/* previous decoded subtitle and related variables */
244
int
got_output
;
245
int
ret
;
246
AVSubtitle
subtitle
;
247
}
prev_sub
;
248
249
struct
sub2video
{
250
int64_t
last_pts
;
251
int64_t
end_pts
;
252
AVFilterBufferRef
*
ref
;
253
int
w
,
h
;
254
}
sub2video
;
255
256
/* a pool of free buffers for decoded data */
257
FrameBuffer
*
buffer_pool
;
258
int
dr1
;
259
260
/* decoded data from this stream goes into all those filters
261
* currently video and audio only */
262
InputFilter
**
filters
;
263
int
nb_filters
;
264
265
int
reinit_filters
;
266
}
InputStream
;
267
268
typedef
struct
InputFile
{
269
AVFormatContext
*
ctx
;
270
int
eof_reached
;
/* true if eof reached */
271
int
eagain
;
/* true if last read attempt returned EAGAIN */
272
int
ist_index
;
/* index of first stream in input_streams */
273
int64_t
ts_offset
;
274
int
nb_streams
;
/* number of stream that ffmpeg is aware of; may be different
275
from ctx.nb_streams if new streams appear during av_read_frame() */
276
int
nb_streams_warn
;
/* number of streams that the user was warned of */
277
int
rate_emu
;
278
279
#if HAVE_PTHREADS
280
pthread_t
thread;
/* thread reading from this file */
281
int
finished;
/* the thread has exited */
282
int
joined;
/* the thread has been joined */
283
pthread_mutex_t
fifo_lock;
/* lock for access to fifo */
284
pthread_cond_t
fifo_cond;
/* the main thread will signal on this cond after reading from fifo */
285
AVFifoBuffer
*fifo;
/* demuxed packets are stored here; freed by the main thread */
286
#endif
287
}
InputFile
;
288
289
typedef
struct
OutputStream
{
290
int
file_index
;
/* file index */
291
int
index
;
/* stream index in the output file */
292
int
source_index
;
/* InputStream index */
293
AVStream
*
st
;
/* stream in the output file */
294
int
encoding_needed
;
/* true if encoding needed for this stream */
295
int
frame_number
;
296
/* input pts and corresponding output pts
297
for A/V sync */
298
struct
InputStream
*
sync_ist
;
/* input stream to sync against */
299
int64_t
sync_opts
;
/* output frame counter, could be changed to some true timestamp */
// FIXME look at frame_number
300
/* pts of the first frame encoded for this stream, used for limiting
301
* recording time */
302
int64_t
first_pts
;
303
AVBitStreamFilterContext
*
bitstream_filters
;
304
AVCodec
*
enc
;
305
int64_t
max_frames
;
306
AVFrame
*
filtered_frame
;
307
308
/* video only */
309
AVRational
frame_rate
;
310
int
force_fps
;
311
int
top_field_first
;
312
313
float
frame_aspect_ratio
;
314
315
/* forced key frames */
316
int64_t *
forced_kf_pts
;
317
int
forced_kf_count
;
318
int
forced_kf_index
;
319
char
*
forced_keyframes
;
320
321
/* audio only */
322
int
audio_channels_map
[
SWR_CH_MAX
];
/* list of the channels id to pick from the source stream */
323
int
audio_channels_mapped
;
/* number of channels in audio_channels_map */
324
325
char
*
logfile_prefix
;
326
FILE *
logfile
;
327
328
OutputFilter
*
filter
;
329
char
*
avfilter
;
330
331
int64_t
sws_flags
;
332
int64_t
swr_filter_type
;
333
int64_t
swr_dither_method
;
334
double
swr_dither_scale
;
335
AVDictionary
*
opts
;
336
int
finished
;
/* no more packets should be written for this stream */
337
int
unavailable
;
/* true if the steram is unavailable (possibly temporarily) */
338
int
stream_copy
;
339
const
char
*
attachment_filename
;
340
int
copy_initial_nonkeyframes
;
341
int
copy_prior_start
;
342
343
int
keep_pix_fmt
;
344
}
OutputStream
;
345
346
typedef
struct
OutputFile
{
347
AVFormatContext
*
ctx
;
348
AVDictionary
*
opts
;
349
int
ost_index
;
/* index of the first stream in output_streams */
350
int64_t
recording_time
;
///< desired length of the resulting file in microseconds == AV_TIME_BASE units
351
int64_t
start_time
;
///< start time in microseconds == AV_TIME_BASE units
352
uint64_t
limit_filesize
;
/* filesize limit expressed in bytes */
353
354
int
shortest
;
355
}
OutputFile
;
356
357
extern
InputStream
**
input_streams
;
358
extern
int
nb_input_streams
;
359
extern
InputFile
**
input_files
;
360
extern
int
nb_input_files
;
361
362
extern
OutputStream
**
output_streams
;
363
extern
int
nb_output_streams
;
364
extern
OutputFile
**
output_files
;
365
extern
int
nb_output_files
;
366
367
extern
FilterGraph
**
filtergraphs
;
368
extern
int
nb_filtergraphs
;
369
370
extern
char
*
vstats_filename
;
371
372
extern
float
audio_drift_threshold
;
373
extern
float
dts_delta_threshold
;
374
extern
float
dts_error_threshold
;
375
376
extern
int
audio_volume
;
377
extern
int
audio_sync_method
;
378
extern
int
video_sync_method
;
379
extern
int
do_benchmark
;
380
extern
int
do_benchmark_all
;
381
extern
int
do_deinterlace
;
382
extern
int
do_hex_dump
;
383
extern
int
do_pkt_dump
;
384
extern
int
copy_ts
;
385
extern
int
copy_tb
;
386
extern
int
debug_ts
;
387
extern
int
exit_on_error
;
388
extern
int
print_stats
;
389
extern
int
qp_hist
;
390
extern
int
stdin_interaction
;
391
extern
int
frame_bits_per_raw_sample
;
392
extern
AVIOContext
*
progress_avio
;
393
394
extern
const
AVIOInterruptCB
int_cb
;
395
396
extern
const
OptionDef
options
[];
397
398
void
term_init
(
void
);
399
void
term_exit
(
void
);
400
401
void
reset_options
(
OptionsContext
*o,
int
is_input);
402
void
show_usage
(
void
);
403
404
void
opt_output_file
(
void
*optctx,
const
char
*filename);
405
406
void
assert_avoptions
(
AVDictionary
*
m
);
407
408
int
guess_input_channel_layout
(
InputStream
*ist);
409
410
enum
AVPixelFormat
choose_pixel_fmt
(
AVStream
*st,
AVCodec
*codec,
enum
AVPixelFormat
target);
411
void
choose_sample_fmt
(
AVStream
*st,
AVCodec
*codec);
412
413
int
configure_filtergraph
(
FilterGraph
*fg);
414
int
configure_output_filter
(
FilterGraph
*fg,
OutputFilter
*ofilter,
AVFilterInOut
*out);
415
int
ist_in_filtergraph
(
FilterGraph
*fg,
InputStream
*ist);
416
FilterGraph
*
init_simple_filtergraph
(
InputStream
*ist,
OutputStream
*ost);
417
418
int
ffmpeg_parse_options
(
int
argc,
char
**argv);
419
420
#endif
/* FFMPEG_H */
Generated on Sat May 25 2013 03:58:29 for FFmpeg by
1.8.2