FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
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
41
#include "
libavutil/avutil.h
"
42
#include "
libavutil/dict.h
"
43
#include "
libavutil/eval.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
int64_t
stop_time
;
117
uint64_t
limit_filesize
;
118
float
mux_preload
;
119
float
mux_max_delay
;
120
int
shortest
;
121
122
int
video_disable
;
123
int
audio_disable
;
124
int
subtitle_disable
;
125
int
data_disable
;
126
127
/* indexed by output file stream index */
128
int
*
streamid_map
;
129
int
nb_streamid_map
;
130
131
SpecifierOpt
*
metadata
;
132
int
nb_metadata
;
133
SpecifierOpt
*
max_frames
;
134
int
nb_max_frames
;
135
SpecifierOpt
*
bitstream_filters
;
136
int
nb_bitstream_filters
;
137
SpecifierOpt
*
codec_tags
;
138
int
nb_codec_tags
;
139
SpecifierOpt
*
sample_fmts
;
140
int
nb_sample_fmts
;
141
SpecifierOpt
*
qscale
;
142
int
nb_qscale
;
143
SpecifierOpt
*
forced_key_frames
;
144
int
nb_forced_key_frames
;
145
SpecifierOpt
*
force_fps
;
146
int
nb_force_fps
;
147
SpecifierOpt
*
frame_aspect_ratios
;
148
int
nb_frame_aspect_ratios
;
149
SpecifierOpt
*
rc_overrides
;
150
int
nb_rc_overrides
;
151
SpecifierOpt
*
intra_matrices
;
152
int
nb_intra_matrices
;
153
SpecifierOpt
*
inter_matrices
;
154
int
nb_inter_matrices
;
155
SpecifierOpt
*
top_field_first
;
156
int
nb_top_field_first
;
157
SpecifierOpt
*
metadata_map
;
158
int
nb_metadata_map
;
159
SpecifierOpt
*
presets
;
160
int
nb_presets
;
161
SpecifierOpt
*
copy_initial_nonkeyframes
;
162
int
nb_copy_initial_nonkeyframes
;
163
SpecifierOpt
*
copy_prior_start
;
164
int
nb_copy_prior_start
;
165
SpecifierOpt
*
filters
;
166
int
nb_filters
;
167
SpecifierOpt
*
filter_scripts
;
168
int
nb_filter_scripts
;
169
SpecifierOpt
*
reinit_filters
;
170
int
nb_reinit_filters
;
171
SpecifierOpt
*
fix_sub_duration
;
172
int
nb_fix_sub_duration
;
173
SpecifierOpt
*
canvas_sizes
;
174
int
nb_canvas_sizes
;
175
SpecifierOpt
*
pass
;
176
int
nb_pass
;
177
SpecifierOpt
*
passlogfiles
;
178
int
nb_passlogfiles
;
179
SpecifierOpt
*
guess_layout_max
;
180
int
nb_guess_layout_max
;
181
SpecifierOpt
*
apad
;
182
int
nb_apad
;
183
}
OptionsContext
;
184
185
typedef
struct
InputFilter
{
186
AVFilterContext
*
filter
;
187
struct
InputStream
*
ist
;
188
struct
FilterGraph
*
graph
;
189
uint8_t
*
name
;
190
}
InputFilter
;
191
192
typedef
struct
OutputFilter
{
193
AVFilterContext
*
filter
;
194
struct
OutputStream
*
ost
;
195
struct
FilterGraph
*
graph
;
196
uint8_t
*
name
;
197
198
/* temporary storage until stream maps are processed */
199
AVFilterInOut
*
out_tmp
;
200
}
OutputFilter
;
201
202
typedef
struct
FilterGraph
{
203
int
index
;
204
const
char
*
graph_desc
;
205
206
AVFilterGraph
*
graph
;
207
int
reconfiguration
;
208
209
InputFilter
**
inputs
;
210
int
nb_inputs
;
211
OutputFilter
**
outputs
;
212
int
nb_outputs
;
213
}
FilterGraph
;
214
215
typedef
struct
InputStream
{
216
int
file_index
;
217
AVStream
*
st
;
218
int
discard
;
/* true if stream data should be discarded */
219
int
decoding_needed
;
/* true if the packets must be decoded in 'raw_fifo' */
220
AVCodec
*
dec
;
221
AVFrame
*
decoded_frame
;
222
AVFrame
*
filter_frame
;
/* a ref of decoded_frame, to be sent to filters */
223
224
int64_t
start
;
/* time when read started */
225
/* predicted dts of the next packet read for this stream or (when there are
226
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
227
int64_t
next_dts
;
228
int64_t
dts
;
///< dts of the last packet read for this stream (in AV_TIME_BASE units)
229
230
int64_t
next_pts
;
///< synthetic pts for the next decode frame (in AV_TIME_BASE units)
231
int64_t
pts
;
///< current pts of the decoded frame (in AV_TIME_BASE units)
232
int
wrap_correction_done
;
233
234
int64_t
filter_in_rescale_delta_last
;
235
236
double
ts_scale
;
237
int
is_start
;
/* is 1 at the start and after a discontinuity */
238
int
saw_first_ts
;
239
int
showed_multi_packet_warning
;
240
AVDictionary
*
opts
;
241
AVRational
framerate
;
/* framerate forced with -r */
242
int
top_field_first
;
243
int
guess_layout_max
;
244
245
int
resample_height
;
246
int
resample_width
;
247
int
resample_pix_fmt
;
248
249
int
resample_sample_fmt
;
250
int
resample_sample_rate
;
251
int
resample_channels
;
252
uint64_t
resample_channel_layout
;
253
254
int
fix_sub_duration
;
255
struct
{
/* previous decoded subtitle and related variables */
256
int
got_output
;
257
int
ret
;
258
AVSubtitle
subtitle
;
259
}
prev_sub
;
260
261
struct
sub2video
{
262
int64_t
last_pts
;
263
int64_t
end_pts
;
264
AVFrame
*
frame
;
265
int
w
,
h
;
266
}
sub2video
;
267
268
int
dr1
;
269
270
/* decoded data from this stream goes into all those filters
271
* currently video and audio only */
272
InputFilter
**
filters
;
273
int
nb_filters
;
274
275
int
reinit_filters
;
276
}
InputStream
;
277
278
typedef
struct
InputFile
{
279
AVFormatContext
*
ctx
;
280
int
eof_reached
;
/* true if eof reached */
281
int
eagain
;
/* true if last read attempt returned EAGAIN */
282
int
ist_index
;
/* index of first stream in input_streams */
283
int64_t
ts_offset
;
284
int64_t
last_ts
;
285
int
nb_streams
;
/* number of stream that ffmpeg is aware of; may be different
286
from ctx.nb_streams if new streams appear during av_read_frame() */
287
int
nb_streams_warn
;
/* number of streams that the user was warned of */
288
int
rate_emu
;
289
290
#if HAVE_PTHREADS
291
pthread_t
thread;
/* thread reading from this file */
292
int
finished;
/* the thread has exited */
293
int
joined;
/* the thread has been joined */
294
pthread_mutex_t
fifo_lock;
/* lock for access to fifo */
295
pthread_cond_t
fifo_cond;
/* the main thread will signal on this cond after reading from fifo */
296
AVFifoBuffer
*fifo;
/* demuxed packets are stored here; freed by the main thread */
297
#endif
298
}
InputFile
;
299
300
enum
forced_keyframes_const
{
301
FKF_N
,
302
FKF_N_FORCED
,
303
FKF_PREV_FORCED_N
,
304
FKF_PREV_FORCED_T
,
305
FKF_T
,
306
FKF_NB
307
};
308
309
extern
const
char
*
const
forced_keyframes_const_names
[];
310
311
typedef
struct
OutputStream
{
312
int
file_index
;
/* file index */
313
int
index
;
/* stream index in the output file */
314
int
source_index
;
/* InputStream index */
315
AVStream
*
st
;
/* stream in the output file */
316
int
encoding_needed
;
/* true if encoding needed for this stream */
317
int
frame_number
;
318
/* input pts and corresponding output pts
319
for A/V sync */
320
struct
InputStream
*
sync_ist
;
/* input stream to sync against */
321
int64_t
sync_opts
;
/* output frame counter, could be changed to some true timestamp */
// FIXME look at frame_number
322
/* pts of the first frame encoded for this stream, used for limiting
323
* recording time */
324
int64_t
first_pts
;
325
/* dts of the last packet sent to the muxer */
326
int64_t
last_mux_dts
;
327
AVBitStreamFilterContext
*
bitstream_filters
;
328
AVCodec
*
enc
;
329
int64_t
max_frames
;
330
AVFrame
*
filtered_frame
;
331
332
/* video only */
333
AVRational
frame_rate
;
334
int
force_fps
;
335
int
top_field_first
;
336
337
AVRational
frame_aspect_ratio
;
338
339
/* forced key frames */
340
int64_t *
forced_kf_pts
;
341
int
forced_kf_count
;
342
int
forced_kf_index
;
343
char
*
forced_keyframes
;
344
AVExpr
*
forced_keyframes_pexpr
;
345
double
forced_keyframes_expr_const_values
[
FKF_NB
];
346
347
/* audio only */
348
int
audio_channels_map
[
SWR_CH_MAX
];
/* list of the channels id to pick from the source stream */
349
int
audio_channels_mapped
;
/* number of channels in audio_channels_map */
350
351
char
*
logfile_prefix
;
352
FILE *
logfile
;
353
354
OutputFilter
*
filter
;
355
char
*
avfilter
;
356
357
int64_t
sws_flags
;
358
AVDictionary
*
opts
;
359
AVDictionary
*
swr_opts
;
360
AVDictionary
*
resample_opts
;
361
char
*
apad
;
362
int
finished
;
/* no more packets should be written for this stream */
363
int
unavailable
;
/* true if the steram is unavailable (possibly temporarily) */
364
int
stream_copy
;
365
const
char
*
attachment_filename
;
366
int
copy_initial_nonkeyframes
;
367
int
copy_prior_start
;
368
369
int
keep_pix_fmt
;
370
}
OutputStream
;
371
372
typedef
struct
OutputFile
{
373
AVFormatContext
*
ctx
;
374
AVDictionary
*
opts
;
375
int
ost_index
;
/* index of the first stream in output_streams */
376
int64_t
recording_time
;
///< desired length of the resulting file in microseconds == AV_TIME_BASE units
377
int64_t
start_time
;
///< start time in microseconds == AV_TIME_BASE units
378
uint64_t
limit_filesize
;
/* filesize limit expressed in bytes */
379
380
int
shortest
;
381
}
OutputFile
;
382
383
extern
InputStream
**
input_streams
;
384
extern
int
nb_input_streams
;
385
extern
InputFile
**
input_files
;
386
extern
int
nb_input_files
;
387
388
extern
OutputStream
**
output_streams
;
389
extern
int
nb_output_streams
;
390
extern
OutputFile
**
output_files
;
391
extern
int
nb_output_files
;
392
393
extern
FilterGraph
**
filtergraphs
;
394
extern
int
nb_filtergraphs
;
395
396
extern
char
*
vstats_filename
;
397
398
extern
float
audio_drift_threshold
;
399
extern
float
dts_delta_threshold
;
400
extern
float
dts_error_threshold
;
401
402
extern
int
audio_volume
;
403
extern
int
audio_sync_method
;
404
extern
int
video_sync_method
;
405
extern
int
do_benchmark
;
406
extern
int
do_benchmark_all
;
407
extern
int
do_deinterlace
;
408
extern
int
do_hex_dump
;
409
extern
int
do_pkt_dump
;
410
extern
int
copy_ts
;
411
extern
int
copy_tb
;
412
extern
int
debug_ts
;
413
extern
int
exit_on_error
;
414
extern
int
print_stats
;
415
extern
int
qp_hist
;
416
extern
int
stdin_interaction
;
417
extern
int
frame_bits_per_raw_sample
;
418
extern
AVIOContext
*
progress_avio
;
419
420
extern
const
AVIOInterruptCB
int_cb
;
421
422
extern
const
OptionDef
options
[];
423
424
void
term_init
(
void
);
425
void
term_exit
(
void
);
426
427
void
reset_options
(
OptionsContext
*o,
int
is_input);
428
void
show_usage
(
void
);
429
430
void
opt_output_file
(
void
*optctx,
const
char
*filename);
431
432
void
assert_avoptions
(
AVDictionary
*
m
);
433
434
int
guess_input_channel_layout
(
InputStream
*ist);
435
436
enum
AVPixelFormat
choose_pixel_fmt
(
AVStream
*st,
AVCodec
*codec,
enum
AVPixelFormat
target);
437
void
choose_sample_fmt
(
AVStream
*st,
AVCodec
*codec);
438
439
int
configure_filtergraph
(
FilterGraph
*fg);
440
int
configure_output_filter
(
FilterGraph
*fg,
OutputFilter
*ofilter,
AVFilterInOut
*
out
);
441
int
ist_in_filtergraph
(
FilterGraph
*fg,
InputStream
*ist);
442
FilterGraph
*
init_simple_filtergraph
(
InputStream
*ist,
OutputStream
*ost);
443
444
int
ffmpeg_parse_options
(
int
argc,
char
**argv);
445
446
#endif
/* FFMPEG_H */
Generated on Wed Jul 10 2013 23:47:53 for FFmpeg by
1.8.2