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
#include "
libavutil/threadmessage.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_VSCFR 0xfe
56
#define VSYNC_DROP 0xff
57
58
#define MAX_STREAMS 1024
/* arbitrary sanity check value */
59
60
enum
HWAccelID
{
61
HWACCEL_NONE
= 0,
62
HWACCEL_AUTO
,
63
HWACCEL_VDPAU
,
64
HWACCEL_DXVA2
,
65
HWACCEL_VDA
,
66
};
67
68
typedef
struct
HWAccel
{
69
const
char
*
name
;
70
int (*
init
)(
AVCodecContext
*
s
);
71
enum
HWAccelID
id
;
72
enum
AVPixelFormat
pix_fmt
;
73
}
HWAccel
;
74
75
/* select an input stream for an output stream */
76
typedef
struct
StreamMap
{
77
int
disabled
;
/* 1 is this mapping is disabled by a negative map */
78
int
file_index
;
79
int
stream_index
;
80
int
sync_file_index
;
81
int
sync_stream_index
;
82
char
*
linklabel
;
/* name of an output link, for mapping lavfi outputs */
83
}
StreamMap
;
84
85
typedef
struct
{
86
int
file_idx,
stream_idx
, channel_idx;
// input
87
int
ofile_idx,
ostream_idx
;
// output
88
}
AudioChannelMap
;
89
90
typedef
struct
OptionsContext
{
91
OptionGroup
*
g
;
92
93
/* input/output options */
94
int64_t
start_time
;
95
const
char
*
format
;
96
97
SpecifierOpt
*
codec_names
;
98
int
nb_codec_names
;
99
SpecifierOpt
*
audio_channels
;
100
int
nb_audio_channels
;
101
SpecifierOpt
*
audio_sample_rate
;
102
int
nb_audio_sample_rate
;
103
SpecifierOpt
*
frame_rates
;
104
int
nb_frame_rates
;
105
SpecifierOpt
*
frame_sizes
;
106
int
nb_frame_sizes
;
107
SpecifierOpt
*
frame_pix_fmts
;
108
int
nb_frame_pix_fmts
;
109
110
/* input options */
111
int64_t
input_ts_offset
;
112
int
rate_emu
;
113
int
accurate_seek
;
114
int
thread_queue_size
;
115
116
SpecifierOpt
*
ts_scale
;
117
int
nb_ts_scale
;
118
SpecifierOpt
*
dump_attachment
;
119
int
nb_dump_attachment
;
120
SpecifierOpt
*
hwaccels
;
121
int
nb_hwaccels
;
122
SpecifierOpt
*
hwaccel_devices
;
123
int
nb_hwaccel_devices
;
124
125
/* output options */
126
StreamMap
*
stream_maps
;
127
int
nb_stream_maps
;
128
AudioChannelMap
*
audio_channel_maps
;
/* one info entry per -map_channel */
129
int
nb_audio_channel_maps
;
/* number of (valid) -map_channel settings */
130
int
metadata_global_manual
;
131
int
metadata_streams_manual
;
132
int
metadata_chapters_manual
;
133
const
char
**
attachments
;
134
int
nb_attachments
;
135
136
int
chapters_input_file
;
137
138
int64_t
recording_time
;
139
int64_t
stop_time
;
140
uint64_t
limit_filesize
;
141
float
mux_preload
;
142
float
mux_max_delay
;
143
int
shortest
;
144
145
int
video_disable
;
146
int
audio_disable
;
147
int
subtitle_disable
;
148
int
data_disable
;
149
150
/* indexed by output file stream index */
151
int
*
streamid_map
;
152
int
nb_streamid_map
;
153
154
SpecifierOpt
*
metadata
;
155
int
nb_metadata
;
156
SpecifierOpt
*
max_frames
;
157
int
nb_max_frames
;
158
SpecifierOpt
*
bitstream_filters
;
159
int
nb_bitstream_filters
;
160
SpecifierOpt
*
codec_tags
;
161
int
nb_codec_tags
;
162
SpecifierOpt
*
sample_fmts
;
163
int
nb_sample_fmts
;
164
SpecifierOpt
*
qscale
;
165
int
nb_qscale
;
166
SpecifierOpt
*
forced_key_frames
;
167
int
nb_forced_key_frames
;
168
SpecifierOpt
*
force_fps
;
169
int
nb_force_fps
;
170
SpecifierOpt
*
frame_aspect_ratios
;
171
int
nb_frame_aspect_ratios
;
172
SpecifierOpt
*
rc_overrides
;
173
int
nb_rc_overrides
;
174
SpecifierOpt
*
intra_matrices
;
175
int
nb_intra_matrices
;
176
SpecifierOpt
*
inter_matrices
;
177
int
nb_inter_matrices
;
178
SpecifierOpt
*
chroma_intra_matrices
;
179
int
nb_chroma_intra_matrices
;
180
SpecifierOpt
*
top_field_first
;
181
int
nb_top_field_first
;
182
SpecifierOpt
*
metadata_map
;
183
int
nb_metadata_map
;
184
SpecifierOpt
*
presets
;
185
int
nb_presets
;
186
SpecifierOpt
*
copy_initial_nonkeyframes
;
187
int
nb_copy_initial_nonkeyframes
;
188
SpecifierOpt
*
copy_prior_start
;
189
int
nb_copy_prior_start
;
190
SpecifierOpt
*
filters
;
191
int
nb_filters
;
192
SpecifierOpt
*
filter_scripts
;
193
int
nb_filter_scripts
;
194
SpecifierOpt
*
reinit_filters
;
195
int
nb_reinit_filters
;
196
SpecifierOpt
*
fix_sub_duration
;
197
int
nb_fix_sub_duration
;
198
SpecifierOpt
*
canvas_sizes
;
199
int
nb_canvas_sizes
;
200
SpecifierOpt
*
pass
;
201
int
nb_pass
;
202
SpecifierOpt
*
passlogfiles
;
203
int
nb_passlogfiles
;
204
SpecifierOpt
*
guess_layout_max
;
205
int
nb_guess_layout_max
;
206
SpecifierOpt
*
apad
;
207
int
nb_apad
;
208
SpecifierOpt
*
discard
;
209
int
nb_discard
;
210
SpecifierOpt
*
disposition
;
211
int
nb_disposition
;
212
}
OptionsContext
;
213
214
typedef
struct
InputFilter
{
215
AVFilterContext
*
filter
;
216
struct
InputStream
*
ist
;
217
struct
FilterGraph
*
graph
;
218
uint8_t
*
name
;
219
}
InputFilter
;
220
221
typedef
struct
OutputFilter
{
222
AVFilterContext
*
filter
;
223
struct
OutputStream
*
ost
;
224
struct
FilterGraph
*
graph
;
225
uint8_t
*
name
;
226
227
/* temporary storage until stream maps are processed */
228
AVFilterInOut
*
out_tmp
;
229
}
OutputFilter
;
230
231
typedef
struct
FilterGraph
{
232
int
index
;
233
const
char
*
graph_desc
;
234
235
AVFilterGraph
*
graph
;
236
int
reconfiguration
;
237
238
InputFilter
**
inputs
;
239
int
nb_inputs
;
240
OutputFilter
**
outputs
;
241
int
nb_outputs
;
242
}
FilterGraph
;
243
244
typedef
struct
InputStream
{
245
int
file_index
;
246
AVStream
*
st
;
247
int
discard
;
/* true if stream data should be discarded */
248
int
user_set_discard
;
249
int
decoding_needed
;
/* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
250
#define DECODING_FOR_OST 1
251
#define DECODING_FOR_FILTER 2
252
253
AVCodecContext
*
dec_ctx
;
254
AVCodec
*
dec
;
255
AVFrame
*
decoded_frame
;
256
AVFrame
*
filter_frame
;
/* a ref of decoded_frame, to be sent to filters */
257
258
int64_t
start
;
/* time when read started */
259
/* predicted dts of the next packet read for this stream or (when there are
260
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
261
int64_t
next_dts
;
262
int64_t
dts
;
///< dts of the last packet read for this stream (in AV_TIME_BASE units)
263
264
int64_t
next_pts
;
///< synthetic pts for the next decode frame (in AV_TIME_BASE units)
265
int64_t
pts
;
///< current pts of the decoded frame (in AV_TIME_BASE units)
266
int
wrap_correction_done
;
267
268
int64_t
filter_in_rescale_delta_last
;
269
270
double
ts_scale
;
271
int
saw_first_ts
;
272
int
showed_multi_packet_warning
;
273
AVDictionary
*
decoder_opts
;
274
AVRational
framerate
;
/* framerate forced with -r */
275
int
top_field_first
;
276
int
guess_layout_max
;
277
278
int
resample_height
;
279
int
resample_width
;
280
int
resample_pix_fmt
;
281
282
int
resample_sample_fmt
;
283
int
resample_sample_rate
;
284
int
resample_channels
;
285
uint64_t
resample_channel_layout
;
286
287
int
fix_sub_duration
;
288
struct
{
/* previous decoded subtitle and related variables */
289
int
got_output
;
290
int
ret
;
291
AVSubtitle
subtitle
;
292
}
prev_sub
;
293
294
struct
sub2video
{
295
int64_t
last_pts
;
296
int64_t
end_pts
;
297
AVFrame
*
frame
;
298
int
w
,
h
;
299
}
sub2video
;
300
301
int
dr1
;
302
303
/* decoded data from this stream goes into all those filters
304
* currently video and audio only */
305
InputFilter
**
filters
;
306
int
nb_filters
;
307
308
int
reinit_filters
;
309
310
/* hwaccel options */
311
enum
HWAccelID
hwaccel_id
;
312
char
*
hwaccel_device
;
313
314
/* hwaccel context */
315
enum
HWAccelID
active_hwaccel_id
;
316
void
*
hwaccel_ctx
;
317
void
(*
hwaccel_uninit
)(
AVCodecContext
*
s
);
318
int (*
hwaccel_get_buffer
)(
AVCodecContext
*
s
,
AVFrame
*
frame
,
int
flags
);
319
int (*
hwaccel_retrieve_data
)(
AVCodecContext
*
s
,
AVFrame
*
frame
);
320
enum
AVPixelFormat
hwaccel_pix_fmt
;
321
enum
AVPixelFormat
hwaccel_retrieved_pix_fmt
;
322
323
/* stats */
324
// combined size of all the packets read
325
uint64_t
data_size
;
326
/* number of packets successfully read for this stream */
327
uint64_t
nb_packets
;
328
// number of frames/samples retrieved from the decoder
329
uint64_t
frames_decoded
;
330
uint64_t
samples_decoded
;
331
}
InputStream
;
332
333
typedef
struct
InputFile
{
334
AVFormatContext
*
ctx
;
335
int
eof_reached
;
/* true if eof reached */
336
int
eagain
;
/* true if last read attempt returned EAGAIN */
337
int
ist_index
;
/* index of first stream in input_streams */
338
int64_t
input_ts_offset
;
339
int64_t
ts_offset
;
340
int64_t
last_ts
;
341
int64_t
start_time
;
/* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
342
int64_t
recording_time
;
343
int
nb_streams
;
/* number of stream that ffmpeg is aware of; may be different
344
from ctx.nb_streams if new streams appear during av_read_frame() */
345
int
nb_streams_warn
;
/* number of streams that the user was warned of */
346
int
rate_emu
;
347
int
accurate_seek
;
348
349
#if HAVE_PTHREADS
350
AVThreadMessageQueue
*in_thread_queue;
351
pthread_t
thread;
/* thread reading from this file */
352
int
non_blocking;
/* reading packets from the thread should not block */
353
int
joined;
/* the thread has been joined */
354
int
thread_queue_size;
/* maximum number of queued packets */
355
#endif
356
}
InputFile
;
357
358
enum
forced_keyframes_const
{
359
FKF_N
,
360
FKF_N_FORCED
,
361
FKF_PREV_FORCED_N
,
362
FKF_PREV_FORCED_T
,
363
FKF_T
,
364
FKF_NB
365
};
366
367
extern
const
char
*
const
forced_keyframes_const_names
[];
368
369
typedef
enum
{
370
ENCODER_FINISHED
= 1,
371
MUXER_FINISHED
= 2,
372
}
OSTFinished
;
373
374
typedef
struct
OutputStream
{
375
int
file_index
;
/* file index */
376
int
index
;
/* stream index in the output file */
377
int
source_index
;
/* InputStream index */
378
AVStream
*
st
;
/* stream in the output file */
379
int
encoding_needed
;
/* true if encoding needed for this stream */
380
int
frame_number
;
381
/* input pts and corresponding output pts
382
for A/V sync */
383
struct
InputStream
*
sync_ist
;
/* input stream to sync against */
384
int64_t
sync_opts
;
/* output frame counter, could be changed to some true timestamp */
// FIXME look at frame_number
385
/* pts of the first frame encoded for this stream, used for limiting
386
* recording time */
387
int64_t
first_pts
;
388
/* dts of the last packet sent to the muxer */
389
int64_t
last_mux_dts
;
390
AVBitStreamFilterContext
*
bitstream_filters
;
391
AVCodecContext
*
enc_ctx
;
392
AVCodec
*
enc
;
393
int64_t
max_frames
;
394
AVFrame
*
filtered_frame
;
395
AVFrame
*
last_frame
;
396
int
last_droped
;
397
398
/* video only */
399
AVRational
frame_rate
;
400
int
force_fps
;
401
int
top_field_first
;
402
403
AVRational
frame_aspect_ratio
;
404
405
/* forced key frames */
406
int64_t *
forced_kf_pts
;
407
int
forced_kf_count
;
408
int
forced_kf_index
;
409
char
*
forced_keyframes
;
410
AVExpr
*
forced_keyframes_pexpr
;
411
double
forced_keyframes_expr_const_values
[
FKF_NB
];
412
413
/* audio only */
414
int
*
audio_channels_map
;
/* list of the channels id to pick from the source stream */
415
int
audio_channels_mapped
;
/* number of channels in audio_channels_map */
416
417
char
*
logfile_prefix
;
418
FILE *
logfile
;
419
420
OutputFilter
*
filter
;
421
char
*
avfilter
;
422
char
*
filters
;
///< filtergraph associated to the -filter option
423
char
*
filters_script
;
///< filtergraph script associated to the -filter_script option
424
425
int64_t
sws_flags
;
426
AVDictionary
*
encoder_opts
;
427
AVDictionary
*
swr_opts
;
428
AVDictionary
*
resample_opts
;
429
AVDictionary
*
bsf_args
;
430
char
*
apad
;
431
OSTFinished
finished
;
/* no more packets should be written for this stream */
432
int
unavailable
;
/* true if the steram is unavailable (possibly temporarily) */
433
int
stream_copy
;
434
const
char
*
attachment_filename
;
435
int
copy_initial_nonkeyframes
;
436
int
copy_prior_start
;
437
char
*
disposition
;
438
439
int
keep_pix_fmt
;
440
441
AVCodecParserContext
*
parser
;
442
443
/* stats */
444
// combined size of all the packets written
445
uint64_t
data_size
;
446
// number of packets send to the muxer
447
uint64_t
packets_written
;
448
// number of frames/samples sent to the encoder
449
uint64_t
frames_encoded
;
450
uint64_t
samples_encoded
;
451
}
OutputStream
;
452
453
typedef
struct
OutputFile
{
454
AVFormatContext
*
ctx
;
455
AVDictionary
*
opts
;
456
int
ost_index
;
/* index of the first stream in output_streams */
457
int64_t
recording_time
;
///< desired length of the resulting file in microseconds == AV_TIME_BASE units
458
int64_t
start_time
;
///< start time in microseconds == AV_TIME_BASE units
459
uint64_t
limit_filesize
;
/* filesize limit expressed in bytes */
460
461
int
shortest
;
462
}
OutputFile
;
463
464
extern
InputStream
**
input_streams
;
465
extern
int
nb_input_streams
;
466
extern
InputFile
**
input_files
;
467
extern
int
nb_input_files
;
468
469
extern
OutputStream
**
output_streams
;
470
extern
int
nb_output_streams
;
471
extern
OutputFile
**
output_files
;
472
extern
int
nb_output_files
;
473
474
extern
FilterGraph
**
filtergraphs
;
475
extern
int
nb_filtergraphs
;
476
477
extern
char
*
vstats_filename
;
478
extern
char
*
sdp_filename
;
479
480
extern
float
audio_drift_threshold
;
481
extern
float
dts_delta_threshold
;
482
extern
float
dts_error_threshold
;
483
484
extern
int
audio_volume
;
485
extern
int
audio_sync_method
;
486
extern
int
video_sync_method
;
487
extern
float
frame_drop_threshold
;
488
extern
int
do_benchmark
;
489
extern
int
do_benchmark_all
;
490
extern
int
do_deinterlace
;
491
extern
int
do_hex_dump
;
492
extern
int
do_pkt_dump
;
493
extern
int
copy_ts
;
494
extern
int
start_at_zero
;
495
extern
int
copy_tb
;
496
extern
int
debug_ts
;
497
extern
int
exit_on_error
;
498
extern
int
print_stats
;
499
extern
int
qp_hist
;
500
extern
int
stdin_interaction
;
501
extern
int
frame_bits_per_raw_sample
;
502
extern
AVIOContext
*
progress_avio
;
503
extern
float
max_error_rate
;
504
extern
int
vdpau_api_ver
;
505
506
extern
const
AVIOInterruptCB
int_cb
;
507
508
extern
const
OptionDef
options
[];
509
extern
const
HWAccel
hwaccels
[];
510
511
512
void
term_init
(
void
);
513
void
term_exit
(
void
);
514
515
void
reset_options
(
OptionsContext
*o,
int
is_input);
516
void
show_usage
(
void
);
517
518
void
opt_output_file
(
void
*optctx,
const
char
*filename);
519
520
void
remove_avoptions
(
AVDictionary
**
a
,
AVDictionary
*
b
);
521
void
assert_avoptions
(
AVDictionary
*
m
);
522
523
int
guess_input_channel_layout
(
InputStream
*ist);
524
525
enum
AVPixelFormat
choose_pixel_fmt
(
AVStream
*st,
AVCodecContext
*avctx,
AVCodec
*codec,
enum
AVPixelFormat
target);
526
void
choose_sample_fmt
(
AVStream
*st,
AVCodec
*codec);
527
528
int
configure_filtergraph
(
FilterGraph
*fg);
529
int
configure_output_filter
(
FilterGraph
*fg,
OutputFilter
*ofilter,
AVFilterInOut
*
out
);
530
int
ist_in_filtergraph
(
FilterGraph
*fg,
InputStream
*ist);
531
FilterGraph
*
init_simple_filtergraph
(
InputStream
*ist,
OutputStream
*ost);
532
533
int
ffmpeg_parse_options
(
int
argc,
char
**argv);
534
535
int
vdpau_init
(
AVCodecContext
*
s
);
536
int
dxva2_init
(
AVCodecContext
*
s
);
537
int
vda_init
(
AVCodecContext
*
s
);
538
539
#endif
/* FFMPEG_H */
Generated on Sun Mar 8 2015 02:34:45 for FFmpeg by
1.8.2