-
Notifications
You must be signed in to change notification settings - Fork 56
/
pyffmpeg.pyx
5034 lines (4253 loc) · 218 KB
/
pyffmpeg.pyx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
##################################################################################
# PyFFmpeg v2.3
#
# Copyright (C) 2011-2015 Martin Haller <[email protected]>
# Copyright (C) 2011 Bertrand Nouvel <[email protected]>
# Copyright (C) 2008-2010 Bertrand Nouvel <[email protected]>
# Japanese French Laboratory for Informatics - CNRS
#
##################################################################################
# This file is distibuted under LGPL-3.0
# See COPYING file attached.
##################################################################################
#
# TODO:
# * check motion vector related functions
# * why seek_before mandatory
# * Add support for video encoding
# * add multithread support
# * Fix first frame bug...
#
# Abilities
# * Frame seeking (TO BE CHECKED again and again)
#
# Changed compared with PyFFmpeg version 1.0:
# * Clean up destructors
# * Added compatibility with NumPy and PIL
# * Added copyless mode for ordered streams/tracks ( when buffers are disabled)
# * Added audio support
# * MultiTrack support (possibility to pass paramer)
# * Added support for streamed video
# * Updated ID for compatibility with transparency
# * Updated to latest avcodec primitives
#
##################################################################################
# Based on Pyffmpeg 0.2 by
# Copyright (C) 2006-2007 James Evans <[email protected]>
# Authorization to change from GPL2.0 to LGPL 3.0 provided by original author for
# this new version
##################################################################################
"""
##################################################################################
# Settings
##################################################################################
AVCODEC_MAX_AUDIO_FRAME_SIZE=192000
AVPROBE_PADDING_SIZE=32
OUTPUTMODE_NUMPY=0
OUTPUTMODE_PIL=1
##################################################################################
# Declaration and imports
##################################################################################
import sys
import traceback
##################################################################################
# ffmpeg uses following integer types
ctypedef signed char int8_t
ctypedef unsigned char uint8_t
ctypedef signed short int16_t
ctypedef unsigned short uint16_t
ctypedef signed long int32_t
ctypedef unsigned long uint32_t
ctypedef signed long long int64_t
ctypedef unsigned long long uint64_t
# other types
ctypedef char const_char "const char"
ctypedef AVCodecContext const_AVCodecContext "const AVCodecContext"
ctypedef struct const_struct_AVSubtitle "const struct AVSubtitle"
ctypedef AVFrame const_AVFrame "const AVFrame"
ctypedef AVClass const_AVClass "const AVClass"
ctypedef struct const_struct_AVCodec "const struct AVCodec"
ctypedef AVCodecDescriptor const_AVCodecDescriptor "const AVCodecDescriptor"
##################################################################################
cdef enum:
SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2
##################################################################################
cdef extern from "string.h":
memcpy(void * dst, void * src, unsigned long sz)
memset(void * dst, unsigned char c, unsigned long sz)
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/mathematics.h":
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/mem.h":
void *av_mallocz(size_t size)
void *av_realloc(void * ptr, size_t size)
void av_free(void *ptr)
void av_freep(void *ptr)
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/rational.h":
struct AVRational:
int num #< numerator
int den #< denominator
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/version.h":
DEF LIBAVUTIL_VERSION_MAJOR = 54
DEF LIBAVUTIL_VERSION_MINOR = 20
DEF LIBAVUTIL_VERSION_MICRO = 100
enum:
FF_API_OLD_AVOPTIONS = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_PIX_FMT = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_CONTEXT_SIZE = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_PIX_FMT_DESC = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_AV_REVERSE = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_AUDIOCONVERT = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_CPU_FLAG_MMX2 = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_LLS_PRIVATE = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_AVFRAME_LAVC = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_VDPAU = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_GET_CHANNEL_LAYOUT_COMPAT= (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_XVMC = (LIBAVUTIL_VERSION_MAJOR < 55)
FF_API_OPT_TYPE_METADATA = (LIBAVUTIL_VERSION_MAJOR < 55)
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/opt.h":
enum:
AV_OPT_FLAG_ENCODING_PARAM = 1 #< a generic parameter which can be set by the user for muxing or encoding
AV_OPT_FLAG_DECODING_PARAM = 2 #< a generic parameter which can be set by the user for demuxing or decoding
# deprecated, will be removed in master 55
# IF FF_API_OPT_TYPE_METADATA == 1:
AV_OPT_FLAG_METADATA = 4 #< some data extracted or inserted into the file like title, comment, ...
AV_OPT_FLAG_AUDIO_PARAM = 8
AV_OPT_FLAG_VIDEO_PARAM = 16
AV_OPT_FLAG_SUBTITLE_PARAM = 32
AV_OPT_FLAG_EXPORT = 64 #< The option is inteded for exporting values to the caller.
AV_OPT_FLAG_READONLY = 128
AV_OPT_FLAG_FILTERING_PARAM = (1<<16) #< a generic parameter which can be set by the user for filtering
enum AVOptionType:
AV_OPT_TYPE_FLAGS,
AV_OPT_TYPE_INT,
AV_OPT_TYPE_INT64,
AV_OPT_TYPE_DOUBLE,
AV_OPT_TYPE_FLOAT,
AV_OPT_TYPE_STRING,
AV_OPT_TYPE_RATIONAL,
AV_OPT_TYPE_BINARY, #< offset must point to a pointer immediately followed by an int for the length
AV_OPT_TYPE_DICT,
AV_OPT_TYPE_CONST = 128,
AV_OPT_TYPE_IMAGE_SIZE = 0x53495a45, # MKBETAG('S','I','Z','E')
AV_OPT_TYPE_PIXEL_FMT = 0x50464d54, # MKBETAG('P','F','M','T')
AV_OPT_TYPE_SAMPLE_FMT = 0x53464d54, # MKBETAG('S','F','M','T')
AV_OPT_TYPE_VIDEO_RATE = 0x56524154, # MKBETAG('V','R','A','T')
AV_OPT_TYPE_DURATION = 0x44555220, # MKBETAG('D','U','R',' ')
AV_OPT_TYPE_COLOR = 0x434f4c52, # MKBETAG('C','O','L','R')
AV_OPT_TYPE_CHANNEL_LAYOUT = 0x43484c41, # MKBETAG('C','H','L','A')
# BEGIN deprecated, will be removed in major 55
FF_OPT_TYPE_FLAGS = 0,
FF_OPT_TYPE_INT,
FF_OPT_TYPE_INT64,
FF_OPT_TYPE_DOUBLE,
FF_OPT_TYPE_FLOAT,
FF_OPT_TYPE_STRING,
FF_OPT_TYPE_RATIONAL,
FF_OPT_TYPE_BINARY, #< offset must point to a pointer immediately followed by an int for the length
FF_OPT_TYPE_CONST=128
# END deprecated, will be removed in major 55
union AVOptionDefaultValUnion:
int64_t i64
double dbl
const_char *str
AVRational q
struct AVOption:
const_char *name
const_char *help #< short English help text
int offset
AVOptionType type
AVOptionDefaultValUnion default_val
double min #< minimum valid value for the option
double max #< maximum valid value for the option
int flags
const_char *unit #< The logical unit to which the option belongs
struct AVOptionRange:
const_char *str
double value_min
double value_max
double component_min
double component_max
int is_range
struct AVOptionRanges:
AVOptionRange **range #< Array of option ranges
int nb_ranges #< Number of ranges per component
int nb_components #< Number of componentes
int av_opt_set (void *obj, char *name, const char *val, int search_flags)
int av_opt_set_int (void *obj, char *name, int64_t val, int search_flags)
int av_opt_set_double (void *obj, char *name, double val, int search_flags)
int av_opt_set_q (void *obj, char *name, AVRational val, int search_flags)
int av_opt_set_bin (void *obj, char *name, uint8_t *val, int size, int search_flags)
int av_opt_set_image_size(void *obj, char *name, int w, int h, int search_flags)
int av_opt_set_pixel_fmt (void *obj, char *name, AVPixelFormat fmt, int search_flags)
int av_opt_set_sample_fmt(void *obj, char *name, AVSampleFormat fmt, int search_flags)
int av_opt_set_video_rate(void *obj, char *name, AVRational val, int search_flags)
int av_opt_set_channel_layout(void *obj, char *name, int64_t ch_layout, int search_flags)
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/log.h":
enum AVClassCategory:
AV_CLASS_CATEGORY_NA = 0,
AV_CLASS_CATEGORY_INPUT,
AV_CLASS_CATEGORY_OUTPUT,
AV_CLASS_CATEGORY_MUXER,
AV_CLASS_CATEGORY_DEMUXER,
AV_CLASS_CATEGORY_ENCODER,
AV_CLASS_CATEGORY_DECODER,
AV_CLASS_CATEGORY_FILTER,
AV_CLASS_CATEGORY_BITSTREAM_FILTER,
AV_CLASS_CATEGORY_SWSCALER,
AV_CLASS_CATEGORY_SWRESAMPLER,
AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT = 40,
AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT,
AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT,
AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT,
AV_CLASS_CATEGORY_DEVICE_OUTPUT,
AV_CLASS_CATEGORY_DEVICE_INPUT,
AV_CLASS_CATEGORY_NB
struct AVClass:
char* class_name
char* (*item_name)(void* ctx)
AVOption *option
int version
int log_level_offset_offset
int parent_log_context_offset
AVClass* (*child_class_next)(AVClass *prev)
AVClassCategory category
AVClassCategory (*get_category)(void* ctx)
int (*query_ranges)(AVOptionRanges **, void *obj, const_char *key, int flags)
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/dict.h":
enum:
AV_DICT_MATCH_CASE = 1 #< Only get an entry with exact-case key match. Only relevant in av_dict_get().
AV_DICT_IGNORE_SUFFIX = 2 #< Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string. Only relevant in av_dict_get().
AV_DICT_DONT_STRDUP_KEY = 4 #< Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
AV_DICT_DONT_STRDUP_VAL = 8 #< Take ownership of a value that's been allocated with av_malloc() or another memory allocation function.
AV_DICT_DONT_OVERWRITE = 16 #< Don't overwrite existing entries.
AV_DICT_APPEND = 32 #< If the entry already exists, append to it. Note that no delimiter is added, the strings are simply concatenated.
struct AVDictionaryEntry:
char *key
char *value
ctypedef struct AVDictionary
# Get number of entries in dictionary.
int av_dict_count(const AVDictionary *m)
# Set the given entry in *pm, overwriting an existing entry.
int av_dict_set(AVDictionary **pm, char *key, char *value, int flags)
# Convenience wrapper for av_dict_set that converts the value to a string
# and stores it.
int av_dict_set_int(AVDictionary **pm, char *key, int64_t value, int flags)
# Free all the memory allocated for an AVDictionary struct
void av_dict_free(AVDictionary **m)
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/buffer.h":
ctypedef struct AVBuffer
struct AVBufferRef:
AVBuffer *buffer
uint8_t *data #< The data buffer
int size #< Size of data in bytes
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/pixfmt.h":
enum AVPixelFormat:
AV_PIX_FMT_NONE = -1,
AV_PIX_FMT_YUV420P, #< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
AV_PIX_FMT_YUYV422, #< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
AV_PIX_FMT_RGB24, #< packed RGB 8:8:8, 24bpp, RGBRGB...
AV_PIX_FMT_BGR24, #< packed RGB 8:8:8, 24bpp, BGRBGR...
AV_PIX_FMT_YUV422P, #< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AV_PIX_FMT_YUV444P, #< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
AV_PIX_FMT_YUV410P, #< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
AV_PIX_FMT_YUV411P, #< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
AV_PIX_FMT_GRAY8, #< Y , 8bpp
AV_PIX_FMT_MONOWHITE, #< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb
AV_PIX_FMT_MONOBLACK, #< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb
AV_PIX_FMT_PAL8, #< 8 bit with PIX_FMT_RGB32 palette
AV_PIX_FMT_YUVJ420P, #< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
AV_PIX_FMT_YUVJ422P, #< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
AV_PIX_FMT_YUVJ444P, #< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
# if FF_API_XVMC
# deprecated, will be removed in major 55
AV_PIX_FMT_XVMC_MPEG2_MC, #< XVideo Motion Acceleration via common packet passing
AV_PIX_FMT_XVMC_MPEG2_IDCT,
# endif /* FF_API_XVMC */
AV_PIX_FMT_UYVY422, #< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
AV_PIX_FMT_UYYVYY411, #< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
AV_PIX_FMT_BGR8, #< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
AV_PIX_FMT_BGR4, #< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
AV_PIX_FMT_BGR4_BYTE, #< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
AV_PIX_FMT_RGB8, #< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
AV_PIX_FMT_RGB4, #< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
AV_PIX_FMT_RGB4_BYTE, #< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
AV_PIX_FMT_NV12, #< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
AV_PIX_FMT_NV21, #< as above, but U and V bytes are swapped
AV_PIX_FMT_ARGB, #< packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
AV_PIX_FMT_RGBA, #< packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
AV_PIX_FMT_ABGR, #< packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
AV_PIX_FMT_BGRA, #< packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
AV_PIX_FMT_GRAY16BE, #< Y , 16bpp, big-endian
AV_PIX_FMT_GRAY16LE, #< Y , 16bpp, little-endian
AV_PIX_FMT_YUV440P, #< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
AV_PIX_FMT_YUVJ440P, #< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range
AV_PIX_FMT_YUVA420P, #< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
# if FF_API_VDPAU
# deprecated, will be removed in major 55
AV_PIX_FMT_VDPAU_H264, #< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
AV_PIX_FMT_VDPAU_MPEG1, #< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
AV_PIX_FMT_VDPAU_MPEG2, #< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
AV_PIX_FMT_VDPAU_WMV3, #< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
AV_PIX_FMT_VDPAU_VC1, #< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
# endif
AV_PIX_FMT_RGB48BE, #< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian
AV_PIX_FMT_RGB48LE, #< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian
AV_PIX_FMT_RGB565BE, #< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
AV_PIX_FMT_RGB565LE, #< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
AV_PIX_FMT_RGB555BE, #< packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
AV_PIX_FMT_RGB555LE, #< packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
AV_PIX_FMT_BGR565BE, #< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
AV_PIX_FMT_BGR565LE, #< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
AV_PIX_FMT_BGR555BE, #< packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
AV_PIX_FMT_BGR555LE, #< packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined
AV_PIX_FMT_VAAPI_MOCO, #< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
AV_PIX_FMT_VAAPI_IDCT, #< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
AV_PIX_FMT_VAAPI_VLD, #< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
AV_PIX_FMT_YUV420P16LE, #< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV420P16BE, #< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AV_PIX_FMT_YUV422P16LE, #< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_YUV422P16BE, #< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_YUV444P16LE, #< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AV_PIX_FMT_YUV444P16BE, #< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
AV_PIX_FMT_VDPAU_MPEG4, #< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
AV_PIX_FMT_DXVA2_VLD, #< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
AV_PIX_FMT_RGB444LE, #< packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined
AV_PIX_FMT_RGB444BE, #< packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
AV_PIX_FMT_BGR444LE, #< packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined
AV_PIX_FMT_BGR444BE, #< packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined
AV_PIX_FMT_YA8, #< 8bit gray, 8bit alpha
AV_PIX_FMT_Y400A = AV_PIX_FMT_YA8, #< alias for AV_PIX_FMT_YA8
AV_PIX_FMT_GRAY8A= AV_PIX_FMT_YA8, #< alias for AV_PIX_FMT_YA8
AV_PIX_FMT_BGR48BE, #< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
AV_PIX_FMT_BGR48LE, #< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
AV_PIX_FMT_YUV420P9BE, #< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AV_PIX_FMT_YUV420P9LE, #< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV420P10BE,#< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AV_PIX_FMT_YUV420P10LE,#< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV422P10BE,#< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_YUV422P10LE,#< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_YUV444P9BE, #< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
AV_PIX_FMT_YUV444P9LE, #< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AV_PIX_FMT_YUV444P10BE,#< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
AV_PIX_FMT_YUV444P10LE,#< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AV_PIX_FMT_YUV422P9BE, #< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_YUV422P9LE, #< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_VDA_VLD, #< hardware decoding through VDA
AV_PIX_FMT_RGBA64BE, #< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
AV_PIX_FMT_RGBA64LE, #< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
AV_PIX_FMT_BGRA64BE, #< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
AV_PIX_FMT_BGRA64LE, #< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
AV_PIX_FMT_GBRP, #< planar GBR 4:4:4 24bpp
AV_PIX_FMT_GBRP9BE, #< planar GBR 4:4:4 27bpp, big-endian
AV_PIX_FMT_GBRP9LE, #< planar GBR 4:4:4 27bpp, little-endian
AV_PIX_FMT_GBRP10BE, #< planar GBR 4:4:4 30bpp, big-endian
AV_PIX_FMT_GBRP10LE, #< planar GBR 4:4:4 30bpp, little-endian
AV_PIX_FMT_GBRP16BE, #< planar GBR 4:4:4 48bpp, big-endian
AV_PIX_FMT_GBRP16LE, #< planar GBR 4:4:4 48bpp, little-endian
AV_PIX_FMT_YUVA422P_LIBAV, #< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
AV_PIX_FMT_YUVA444P_LIBAV, #< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
AV_PIX_FMT_YUVA420P9BE, #< planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
AV_PIX_FMT_YUVA420P9LE, #< planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian
AV_PIX_FMT_YUVA422P9BE, #< planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
AV_PIX_FMT_YUVA422P9LE, #< planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
AV_PIX_FMT_YUVA444P9BE, #< planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
AV_PIX_FMT_YUVA444P9LE, #< planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
AV_PIX_FMT_YUVA420P10BE, #< planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
AV_PIX_FMT_YUVA420P10LE, #< planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
AV_PIX_FMT_YUVA422P10BE, #< planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
AV_PIX_FMT_YUVA422P10LE, #< planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
AV_PIX_FMT_YUVA444P10BE, #< planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
AV_PIX_FMT_YUVA444P10LE, #< planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
AV_PIX_FMT_YUVA420P16BE, #< planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
AV_PIX_FMT_YUVA420P16LE, #< planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
AV_PIX_FMT_YUVA422P16BE, #< planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
AV_PIX_FMT_YUVA422P16LE, #< planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
AV_PIX_FMT_YUVA444P16BE, #< planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
AV_PIX_FMT_YUVA444P16LE, #< planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
AV_PIX_FMT_VDPAU, #< HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface
AV_PIX_FMT_XYZ12LE, #< packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as little-endian, the 4 lower bits are set to 0
AV_PIX_FMT_XYZ12BE, #< packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as big-endian, the 4 lower bits are set to 0
AV_PIX_FMT_NV16, #< interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AV_PIX_FMT_NV20LE, #< interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_NV20BE, #< interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_RGBA64BE_LIBAV, #< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
AV_PIX_FMT_RGBA64LE_LIBAV, #< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
AV_PIX_FMT_BGRA64BE_LIBAV, #< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
AV_PIX_FMT_BGRA64LE_LIBAV, #< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
AV_PIX_FMT_YVYU422, #< packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
AV_PIX_FMT_VDA, #< HW acceleration through VDA, data[3] contains a CVPixelBufferRef
AV_PIX_FMT_YA16BE, #< 16bit gray, 16bit alpha (big-endian)
AV_PIX_FMT_YA16LE, #< 16bit gray, 16bit alpha (little-endian)
AV_PIX_FMT_GBRAP_LIBAV, #< planar GBRA 4:4:4:4 32bpp
AV_PIX_FMT_GBRAP16BE_LIBAV, #< planar GBRA 4:4:4:4 64bpp, big-endian
AV_PIX_FMT_GBRAP16LE_LIBAV, #< planar GBRA 4:4:4:4 64bpp, little-endian
AV_PIX_FMT_QSV,
AV_PIX_FMT_RGBA64BE=0x123, #< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
AV_PIX_FMT_RGBA64LE, #< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
AV_PIX_FMT_BGRA64BE, #< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
AV_PIX_FMT_BGRA64LE, #< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
AV_PIX_FMT_0RGB=0x123+4, #< packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
AV_PIX_FMT_RGB0, #< packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
AV_PIX_FMT_0BGR, #< packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
AV_PIX_FMT_BGR0, #< packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
AV_PIX_FMT_YUVA444P, #< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
AV_PIX_FMT_YUVA422P, #< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
AV_PIX_FMT_YUV420P12BE, #< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AV_PIX_FMT_YUV420P12LE, #< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV420P14BE, #< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AV_PIX_FMT_YUV420P14LE, #< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV422P12BE, #< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_YUV422P12LE, #< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_YUV422P14BE, #< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_YUV422P14LE, #< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_YUV444P12BE, #< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
AV_PIX_FMT_YUV444P12LE, #< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AV_PIX_FMT_YUV444P14BE, #< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
AV_PIX_FMT_YUV444P14LE, #< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AV_PIX_FMT_GBRP12BE, #< planar GBR 4:4:4 36bpp, big-endian
AV_PIX_FMT_GBRP12LE, #< planar GBR 4:4:4 36bpp, little-endian
AV_PIX_FMT_GBRP14BE, #< planar GBR 4:4:4 42bpp, big-endian
AV_PIX_FMT_GBRP14LE, #< planar GBR 4:4:4 42bpp, little-endian
AV_PIX_FMT_GBRAP, #< planar GBRA 4:4:4:4 32bpp
AV_PIX_FMT_GBRAP16BE, #< planar GBRA 4:4:4:4 64bpp, big-endian
AV_PIX_FMT_GBRAP16LE, #< planar GBRA 4:4:4:4 64bpp, little-endian
AV_PIX_FMT_YUVJ411P, #< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor of PIX_FMT_YUV411P and setting color_range
AV_PIX_FMT_BAYER_BGGR8, #< bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples */
AV_PIX_FMT_BAYER_RGGB8, #< bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples */
AV_PIX_FMT_BAYER_GBRG8, #< bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples */
AV_PIX_FMT_BAYER_GRBG8, #< bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples */
AV_PIX_FMT_BAYER_BGGR16LE, #< bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, little-endian */
AV_PIX_FMT_BAYER_BGGR16BE, #< bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, big-endian */
AV_PIX_FMT_BAYER_RGGB16LE, #< bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian */
AV_PIX_FMT_BAYER_RGGB16BE, #< bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, big-endian */
AV_PIX_FMT_BAYER_GBRG16LE, #< bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, little-endian */
AV_PIX_FMT_BAYER_GBRG16BE, #< bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian */
AV_PIX_FMT_BAYER_GRBG16LE, #< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian */
AV_PIX_FMT_BAYER_GRBG16BE, #< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian */
AV_PIX_FMT_XVMC,#< XVideo Motion Acceleration via common packet passing
AV_PIX_FMT_NB, #< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
# ok libavutil/pixfmt.h 54. 20.100
enum AVColorPrimaries:
AVCOL_PRI_BT709 = 1 #< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
AVCOL_PRI_UNSPECIFIED = 2
AVCOL_PRI_BT470M = 4
AVCOL_PRI_BT470BG = 5 #< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
AVCOL_PRI_SMPTE170M = 6 #< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
AVCOL_PRI_SMPTE240M = 7 #< functionally identical to above
AVCOL_PRI_FILM = 8
AVCOL_PRI_BT2020 = 9 #< ITU-R BT2020
AVCOL_PRI_NB = 10 #< Not part of ABI
# ok libavutil/pixfmt.h 54. 20.100
enum AVColorTransferCharacteristic:
AVCOL_TRC_RESERVED0 = 0
AVCOL_TRC_BT709 = 1 #< also ITU-R BT1361
AVCOL_TRC_UNSPECIFIED = 2
AVCOL_TRC_RESERVED = 3
AVCOL_TRC_GAMMA22 = 4 #< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
AVCOL_TRC_GAMMA28 = 5 #< also ITU-R BT470BG
AVCOL_TRC_SMPTE170M = 6 #< also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
AVCOL_TRC_SMPTE240M = 7
AVCOL_TRC_LINEAR = 8 #< "Linear transfer characteristics"
AVCOL_TRC_LOG = 9 #< "Logarithmic transfer characteristic (100:1 range)"
AVCOL_TRC_LOG_SQRT = 10 #< "Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
AVCOL_TRC_IEC61966_2_4 = 11 #< IEC 61966-2-4
AVCOL_TRC_BT1361_ECG = 12 #< ITU-R BT1361 Extended Colour Gamut
AVCOL_TRC_IEC61966_2_1 = 13 #< IEC 61966-2-1 (sRGB or sYCC)
AVCOL_TRC_BT2020_10 = 14 #< ITU-R BT2020 for 10 bit system
AVCOL_TRC_BT2020_12 = 15 #< ITU-R BT2020 for 12 bit system
AVCOL_TRC_NB = 16 #< Not part of ABI
# ok libavutil/pixfmt.h 54. 20.100
enum AVColorSpace:
AVCOL_SPC_RGB = 0 #< order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
AVCOL_SPC_BT709 = 1 #< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
AVCOL_SPC_UNSPECIFIED = 2
AVCOL_SPC_RESERVED = 3
AVCOL_SPC_FCC = 4 #< FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
AVCOL_SPC_BT470BG = 5 #< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
AVCOL_SPC_SMPTE170M = 6 #< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
AVCOL_SPC_SMPTE240M = 7
AVCOL_SPC_YCOCG = 8 #< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
AVCOL_SPC_BT2020_NCL = 9 #< ITU-R BT2020 non-constant luminance system
AVCOL_SPC_BT2020_CL = 10 #< ITU-R BT2020 constant luminance system
AVCOL_SPC_NB = 11 #< Not part of ABI
# ok libavutil/pixfmt.h 54. 20.100
enum AVColorRange:
AVCOL_RANGE_UNSPECIFIED = 0
AVCOL_RANGE_MPEG = 1 #< the normal 219*2^(n-8) "MPEG" YUV ranges
AVCOL_RANGE_JPEG = 2 #< the normal 2^n-1 "JPEG" YUV ranges
AVCOL_RANGE_NB = 3 #< Not part of ABI
# ok libavutil/pixfmt.h 54. 20.100
enum AVChromaLocation:
AVCHROMA_LOC_UNSPECIFIED = 0
AVCHROMA_LOC_LEFT = 1 #< mpeg2/4, h264 default
AVCHROMA_LOC_CENTER = 2 #< mpeg1, jpeg, h263
AVCHROMA_LOC_TOPLEFT = 3 #< DV
AVCHROMA_LOC_TOP = 4
AVCHROMA_LOC_BOTTOMLEFT = 5
AVCHROMA_LOC_BOTTOM = 6
AVCHROMA_LOC_NB = 7 #< Not part of ABI
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/avutil.h":
# from avutil.h
enum AVMediaType:
AVMEDIA_TYPE_UNKNOWN = -1,
AVMEDIA_TYPE_VIDEO,
AVMEDIA_TYPE_AUDIO,
AVMEDIA_TYPE_DATA,
AVMEDIA_TYPE_SUBTITLE,
AVMEDIA_TYPE_ATTACHMENT,
AVMEDIA_TYPE_NB
# ok libavutil/avutil.h 54. 20.100
enum AVPictureType:
AV_PICTURE_TYPE_NONE= 0, #< Undefined
AV_PICTURE_TYPE_BI, #< Intra
AV_PICTURE_TYPE_P, #< Predicted
AV_PICTURE_TYPE_B, #< Bi-dir predicted
AV_PICTURE_TYPE_S, #< S(GMC)-VOP MPEG4
AV_PICTURE_TYPE_SI, #< Switching Intra
AV_PICTURE_TYPE_SP, #< Switching Predicted
AV_PICTURE_TYPE_BI, #< BI type
# unnamed enum for defines
enum:
AV_NOPTS_VALUE = <int64_t>0x8000000000000000
AV_TIME_BASE = 1000000
# this is defined below as variable
# AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/samplefmt.h":
enum AVSampleFormat:
AV_SAMPLE_FMT_NONE = -1,
AV_SAMPLE_FMT_U8, #< unsigned 8 bits
AV_SAMPLE_FMT_S16, #< signed 16 bits
AV_SAMPLE_FMT_S32, #< signed 32 bits
AV_SAMPLE_FMT_FLT, #< float
AV_SAMPLE_FMT_DBL, #< double
AV_SAMPLE_FMT_U8P, #< unsigned 8 bits, planar
AV_SAMPLE_FMT_S16P, #< signed 16 bits, planar
AV_SAMPLE_FMT_S32P, #< signed 32 bits, planar
AV_SAMPLE_FMT_FLTP, #< float, planar
AV_SAMPLE_FMT_DBLP, #< double, planar
AV_SAMPLE_FMT_NB #< Number of sample formats. DO NOT USE if linking dynamically
##################################################################################
# ok libavformat 56. 25.101
cdef extern from "libavformat/avio.h":
struct AVIOInterruptCB:
pass
struct AVIOContext:
AVClass *av_class
unsigned char *buffer
int buffer_size
unsigned char *buf_ptr
unsigned char *buf_end
void *opaque
int *read_packet
int *write_packet
int64_t *seek
int64_t pos
int must_flush
int eof_reached
int write_flag
int max_packet_size
unsigned long checksum
unsigned char *checksum_ptr
unsigned long *update_checksum
int error
int *read_pause
int64_t *read_seek
int seekable
int64_t maxsize
int direct
int64_t bytes_read
int seek_count
int writeout_count
int orig_buffer_size
#int url_setbufsize(AVIOContext *s, int buf_size)
#int url_ferror(AVIOContext *s)
int avio_open(AVIOContext **s, char *url, int flags)
int avio_close(AVIOContext *s)
# Force flushing of buffered data
void avio_flush(AVIOContext *s)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
# fseek() equivalent for AVIOContext
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
# Seek to a given timestamp relative to some component stream.
int64_t avio_seek_time(AVIOContext *s, int stream_index, int64_t timestamp, int flags)
AVIOContext *avio_alloc_context(
unsigned char *buffer,
int buffer_size,
int write_flag,
void *opaque,
void *a,
void *b,
void *c)
#struct ByteIOContext:
# pass
#ctypedef long long int offset_t
#int get_buffer(ByteIOContext *s, unsigned char *buf, int size)
# use avio_read(s, buf, size);
#int url_ferror(ByteIOContext *s)
# use int url_ferror(AVIOContext *s)
#int url_feof(ByteIOContext *s)
# use AVIOContext.eof_reached
#int url_fopen(ByteIOContext **s, char *filename, int flags)
# use avio_open(s, filename, flags);
#int url_setbufsize(ByteIOContext *s, int buf_size)
#use int url_setbufsize(AVIOContext *s, int buf_size);
#int url_fclose(ByteIOContext *s)
# use avio_close(s)
#long long int url_fseek(ByteIOContext *s, long long int offset, int whence)
# use avio_seek(s, offset, whence);
# ByteIOContext *av_alloc_put_byte(
# unsigned char *buffer,
# int buffer_size,
# int write_flag,
# void *opaque,
# void * a , void * b , void * c)
# #int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
# #int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
# #offset_t (*seek)(void *opaque, offset_t offset, int whence))
# use avio_alloc_context(buffer, buffer_size, write_flag, opaque,
# read_packet, write_packet, seek);
##################################################################################
# ok libavutil 54. 20.100
cdef extern from "libavutil/frame.h":
enum:
AV_NUM_DATA_POINTERS = 8
enum AVFrameSideDataType:
AV_FRAME_DATA_PANSCAN, #< The data is the AVPanScan struct defined in libavcodec.
AV_FRAME_DATA_A53_CC, #< ATSC A53 Part 4 Closed Captions.
AV_FRAME_DATA_STEREO3D, #< Stereoscopic 3d metadata.
AV_FRAME_DATA_MATRIXENCODING, #< The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
AV_FRAME_DATA_DOWNMIX_INFO, #< Metadata relevant to a downmix procedure.
AV_FRAME_DATA_REPLAYGAIN, #< ReplayGain information in the form of the AVReplayGain struct.
AV_FRAME_DATA_DISPLAYMATRIX, #< This side data contains a 3x3 transformation matrix describing an affine transformation that needs to be applied to the frame for correct presentation.
AV_FRAME_DATA_AFD, #< Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVActiveFormatDescription enum
AV_FRAME_DATA_MOTION_VECTORS, #< Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec AVCodecContext flags2 option). The data is the AVMotionVector struct defined in libavutil/motion_vector.h
AV_FRAME_DATA_SKIP_SAMPLES, #< Recommmends skipping the specified number of samples
AV_FRAME_DATA_AUDIO_SERVICE_TYPE #< his side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defined in avcodec.h.
enum AVActiveFormatDescription:
AV_AFD_SAME = 8
AV_AFD_4_3 = 9
AV_AFD_16_9 = 10
AV_AFD_14_9 = 11
AV_AFD_4_3_SP_14_9 = 13
AV_AFD_16_9_SP_14_9 = 14
AV_AFD_SP_4_3 = 15
struct AVFrameSideData:
AVFrameSideDataType type
uint8_t *data
int size
AVDictionary *metadata
struct AVFrame:
uint8_t *data[AV_NUM_DATA_POINTERS] #< pointer to the picture planes
int linesize[AV_NUM_DATA_POINTERS] #< For video, size in bytes of each picture line.
uint8_t **extended_data #< pointers to the data planes/channels.
int width #< width of the video frame
int height #< height of the video frame
int nb_samples #< number of audio samples (per channel) described by this frame
int format #< format of the frame, -1 if unknown or unset, Values correspond to enum AVPixelFormat for video frames, enum AVSampleFormat for audio)
int key_frame #< 1 -> keyframe, 0-> not
AVPictureType pict_type #< AVPicture type of the frame, see ?_TYPE below
# BEGIN deprecated, will be removed in major 55
#uint8_t *base[AV_NUM_DATA_POINTERS] #< deprecated, will be removed in major 55
# END deprecated, will be removed in major 55
AVRational sample_aspect_ratio #< Sample aspect ratio for the video frame
int64_t pts #< presentation timestamp in time_base units (time when frame should be shown to user)
int64_t pkt_pts #< PTS copied from the AVPacket that was decoded to produce this frame
int64_t pkt_dts #< DTS copied from the AVPacket that triggered returning this frame
int coded_picture_number #< picture number in bitstream order
int display_picture_number #< picture number in display order
int quality #< quality (between 1 (good) and FF_LAMBDA_MAX (bad))
# BEGIN deprecated, will be removed in major 55
int reference #< is this picture used as reference
int qscale_table #< QP table
int qstride #< QP store stride
int qscale_type
uint8_t *mbskip_table #< mbskip_table[mb]>=1 if MB didn't change, stride= mb_width = (width+15)>>4
int16_t (*motion_val[2])[2] #< motion vector table
uint32_t *mb_type #< macroblock type table: mb_type_base + mb_width + 2
short *dct_coeff #< DCT coefficients
int8_t *ref_index[2] #< motion reference frame index
# END deprecated, will be removed in major 55
void *opaque #< for some private data of the user
uint64_t error[AV_NUM_DATA_POINTERS] #< unused for decodig
# BEGIN deprecated, will be removed in major 55
int type #< type of the buffer (to keep track of who has to deallocate data[*]
# END deprecated, will be removed in major 55
int repeat_pict #< When decoding, this signals how much the picture must be delayed: extra_delay = repeat_pict / (2*fps)
int interlaced_frame #< The content of the picture is interlaced
int top_field_first #< If the content is interlaced, is top field displayed first
int palette_has_changed #< Tell user application that palette has changed from previous frame
# BEGIN deprecated, will be removed in major 55
int buffer_hints #<
AVPanScan *pan_scan #< Pan scan
# END deprecated, will be removed in major 55
# reordered opaque 64bit (generally an integer or a double precision float
# PTS but can be anything).
# The user sets AVCodecContext.reordered_opaque to represent the input at
# that time, the decoder reorders values as needed and sets AVFrame.reordered_opaque
# to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
# @deprecated in favor of pkt_pts
int64_t reordered_opaque
# BEGIN deprecated, will be removed in major 55
void *hwaccel_picture_private #< hardware accelerator private data
AVCodecContext *owner #< the AVCodecContext which ff_thread_get_buffer() was last called on
void *thread_opaque #< used by multithreading to store frame-specific info
uint8_t motion_subsample_log2 #< log2 of the size of the block which a single vector in motion_val represents: (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)
# END deprecated, will be removed in major 55
int sample_rate #< Sample rate of the audio data
uint64_t channel_layout #< Channel layout of the audio data
AVBufferRef *buf[AV_NUM_DATA_POINTERS] #< AVBuffer references backing the data for this frame
AVBufferRef **extended_buf #< For planar audio which requires more than AV_NUM_DATA_POINTERS
int nb_extended_buf #< Number of elements in extended_buf
AVFrameSideData **side_data
int nb_side_data
int flags #< Frame flags, a combination of @ref lavu_frame_flags
AVColorRange color_range #< MPEG vs JPEG YUV range
AVColorPrimaries color_primaries
AVColorTransferCharacteristic color_trc
AVColorSpace colorspace #< YUV colorspace type
AVChromaLocation chroma_location
int64_t best_effort_timestamp #< frame timestamp estimated using various heuristics
int64_t pkt_pos #< reordered pos from the last AVPacket that has been input into the decoder
int64_t pkt_duration #< duration of the corresponding packet, in AVStream->time_base units
AVDictionary *metadata
int decode_error_flags #< decode error flags of the frame, set to a combination of FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there were errors during the decoding.
int channels #< number of audio channels, only used for audio
int pkt_size #< size of the corresponding packet containing the compressed frame
AVBufferRef *qp_table_buf #< Not to be accessed directly from outside libavutil
##################################################################################
# ok libavcodec 56. 26.100
cdef extern from "libavcodec/avcodec.h":
ctypedef struct AVCodecDefault
ctypedef struct AVCodecInternal
enum AVFieldOrder:
AV_FIELD_UNKNOWN,
AV_FIELD_PROGRESSIVE,
AV_FIELD_TT, #< Top coded_first, top displayed first
AV_FIELD_BB, #< Bottom coded first, bottom displayed first
AV_FIELD_TB, #< Top coded first, bottom displayed first
AV_FIELD_BT, #< Bottom coded first, top displayed first
# use an unamed enum for defines
enum:
CODEC_FLAG_QSCALE = 0x0002 #< Use fixed qscale.
CODEC_FLAG_4MV = 0x0004 #< 4 MV per MB allowed / advanced prediction for H.263.
CODEC_FLAG_QPEL = 0x0010 #< Use qpel MC.
CODEC_FLAG_GMC = 0x0020 #< Use GMC.
CODEC_FLAG_MV0 = 0x0040 #< Always try a MB with MV=<0,0>.
CODEC_FLAG_PART = 0x0080 #< Use data partitioning.
# * The parent program guarantees that the input for B-frames containing
# * streams is not written to for at least s->max_b_frames+1 frames, if
# * this is not set the input will be copied.
CODEC_FLAG_INPUT_PRESERVED = 0x0100
CODEC_FLAG_PASS1 = 0x0200 #< Use internal 2pass ratecontrol in first pass mode.
CODEC_FLAG_PASS2 = 0x0400 #< Use internal 2pass ratecontrol in second pass mode.
#CODEC_FLAG_EXTERN_HUFF = 0x1000 #< Use external Huffman table (for MJPEG).
CODEC_FLAG_GRAY = 0x2000 #< Only decode/encode grayscale.
CODEC_FLAG_EMU_EDGE = 0x4000 #< Don't draw edges.
CODEC_FLAG_PSNR = 0x8000 #< error[?] variables will be set during encoding.
CODEC_FLAG_TRUNCATED = 0x00010000 #< Input bitstream might be truncated at a random location instead of only at frame boundaries.
CODEC_FLAG_NORMALIZE_AQP = 0x00020000 #< Normalize adaptive quantization.
CODEC_FLAG_INTERLACED_DCT = 0x00040000 #< Use interlaced DCT.
CODEC_FLAG_LOW_DELAY = 0x00080000 #< Force low delay.
CODEC_FLAG_ALT_SCAN = 0x00100000 #< Use alternate scan.
CODEC_FLAG_GLOBAL_HEADER = 0x00400000 #< Place global headers in extradata instead of every keyframe.
CODEC_FLAG_BITEXACT = 0x00800000 #< Use only bitexact stuff (except (I)DCT).
# Fx : Flag for h263+ extra options
CODEC_FLAG_AC_PRED = 0x01000000 #< H.263 advanced intra coding / MPEG-4 AC prediction
#CODEC_FLAG_H263P_UMV = 0x02000000 #< unlimited motion vector
CODEC_FLAG_LOOP_FILTER = 0x00000800 #< loop filter
CODEC_FLAG_INTERLACED_ME = 0x20000000 #< interlaced motion estimation
CODEC_FLAG_CLOSED_GOP = 0x80000000
CODEC_FLAG2_FAST = 0x00000001 #< Allow non spec compliant speedup tricks.
CODEC_FLAG2_NO_OUTPUT = 0x00000004 #< Skip bitstream encoding.
CODEC_FLAG2_LOCAL_HEADER = 0x00000008 #< Place global headers at every keyframe instead of in extradata.
CODEC_FLAG2_DROP_FRAME_TIMECODE = 0x00002000 #< timecode is in drop frame format. DEPRECATED!!!!
CODEC_FLAG2_IGNORE_CROP = 0x00010000 #< Discard cropping information from SPS.
CODEC_FLAG2_CHUNKS = 0x00008000 #< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
CODEC_FLAG2_SHOW_ALL = 0x00400000 #< Show all frames before the first keyframe
CODEC_FLAG2_EXPORT_MVS = 0x10000000 #< Export motion vectors through frame side data
CODEC_FLAG2_SKIP_MANUAL = 0x20000000 #< Do not skip samples and export skip information as frame side data
# codec capabilities
CODEC_CAP_DRAW_HORIZ_BAND = 0x0001 #< Decoder can use draw_horiz_band callback.
CODEC_CAP_DR1 = 0x0002
#CODEC_CAP_PARSE_ONLY = 0x0004
CODEC_CAP_TRUNCATED = 0x0008
CODEC_CAP_HWACCEL = 0x0010
CODEC_CAP_DELAY = 0x0020
CODEC_CAP_SMALL_LAST_FRAME = 0x0040
CODEC_CAP_HWACCEL_VDPAU = 0x0080
CODEC_CAP_SUBFRAMES = 0x0100
CODEC_CAP_EXPERIMENTAL = 0x0200
CODEC_CAP_CHANNEL_CONF = 0x0400
CODEC_CAP_NEG_LINESIZES = 0x0800
CODEC_CAP_FRAME_THREADS = 0x1000
CODEC_CAP_SLICE_THREADS = 0x2000
CODEC_CAP_PARAM_CHANGE = 0x4000
CODEC_CAP_AUTO_THREADS = 0x8000
CODEC_CAP_VARIABLE_FRAME_SIZE = 0x10000
CODEC_CAP_INTRA_ONLY = 0x40000000
CODEC_CAP_LOSSLESS = 0x80000000
# AVFrame pict_type values DEPRECATED use AVPictureType AV_PICTURE_TYPE_*
FF_I_TYPE = 1 #< Intra
FF_P_TYPE = 2 #< Predicted
FF_B_TYPE = 3 #< Bi-dir predicted
FF_S_TYPE = 4 #< S(GMC)-VOP MPEG4
FF_SI_TYPE = 5 #< Switching Intra
FF_SP_TYPE = 6 #< Switching Predicte
FF_BI_TYPE = 7
# AVFrame mb_type values
#The following defines may change, don't expect compatibility if you use them.
#Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
MB_TYPE_INTRA4x4 = 0x0001
MB_TYPE_INTRA16x16 = 0x0002 #FIXME H.264-specific
MB_TYPE_INTRA_PCM = 0x0004 #FIXME H.264-specific
MB_TYPE_16x16 = 0x0008
MB_TYPE_16x8 = 0x0010
MB_TYPE_8x16 = 0x0020
MB_TYPE_8x8 = 0x0040
MB_TYPE_INTERLACED = 0x0080
MB_TYPE_DIRECT2 = 0x0100 #FIXME
MB_TYPE_ACPRED = 0x0200
MB_TYPE_GMC = 0x0400
MB_TYPE_SKIP = 0x0800
MB_TYPE_P0L0 = 0x1000
MB_TYPE_P1L0 = 0x2000
MB_TYPE_P0L1 = 0x4000
MB_TYPE_P1L1 = 0x8000
MB_TYPE_L0 = (MB_TYPE_P0L0 | MB_TYPE_P1L0)
MB_TYPE_L1 = (MB_TYPE_P0L1 | MB_TYPE_P1L1)
MB_TYPE_L0L1 = (MB_TYPE_L0 | MB_TYPE_L1)
MB_TYPE_QUANT = 0x00010000
MB_TYPE_CBP = 0x00020000
# AVCodecContext compression_level
FF_COMPRESSION_DEFAULT = -1
# AVCodecContext
FF_ASPECT_EXTENDED = 15
# AVCodecContext
FF_RC_STRATEGY_XVID = 1