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