1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 cython,
6 fetchFromGitHub,
7 fetchpatch,
8 ffmpeg_5-headless,
9 numpy,
10 pillow,
11 pkg-config,
12 pytestCheckHook,
13 pythonOlder,
14 setuptools,
15}:
16
17buildPythonPackage rec {
18 pname = "av";
19 version = "11.0.0";
20 pyproject = true;
21
22 disabled = pythonOlder "3.7";
23
24 src = fetchFromGitHub {
25 owner = "mikeboers";
26 repo = "PyAV";
27 rev = "refs/tags/v${version}";
28 hash = "sha256-pCKP+4ZmZCJcG7/Qy9H6aS4svQdgaRA9S1QVNWFYhSQ=";
29 };
30
31 patches = [
32 # merged upstream PR: https://github.com/PyAV-Org/PyAV/pull/1387
33 (fetchpatch {
34 name = "use-pkg-config-env-var-fix-cross.patch";
35 url = "https://github.com/PyAV-Org/PyAV/commit/ba7a2c9f716af506838d399e6ed27ed6d64d2435.patch";
36 sha256 = "sha256-oH+g8sVoVCQe6DimRN38VT2GdziriwHYRAhldNxz9/E=";
37 })
38 ];
39
40 nativeBuildInputs = [
41 cython
42 pkg-config
43 setuptools
44 ];
45
46 buildInputs = [ ffmpeg_5-headless ];
47
48 preCheck = ''
49 # ensure we import the built version
50 rm -r av
51 '';
52
53 nativeCheckInputs = [
54 numpy
55 pillow
56 pytestCheckHook
57 ];
58
59 disabledTests =
60 [
61 # urlopen fails during DNS resolution
62 "test_writing_to_custom_io"
63 "test_decode_close_then_use"
64 # Tests that want to download FATE data, https://github.com/PyAV-Org/PyAV/issues/955
65 "test_vobsub"
66 "test_transcode"
67 "test_stream_tuples"
68 "test_stream_seek"
69 "test_stream_probing"
70 "test_seek_start"
71 "test_seek_middle"
72 "test_seek_int64"
73 "test_seek_float"
74 "test_seek_end"
75 "test_roundtrip"
76 "test_reading_from_write_readonl"
77 "test_reading_from_pipe_readonly"
78 "test_reading_from_file"
79 "test_reading_from_buffer"
80 "test_reading_from_buffer_no_see"
81 "test_parse"
82 "test_movtext"
83 "test_encoding_xvid"
84 "test_encoding_tiff"
85 "test_encoding_png"
86 "test_encoding_pcm_s24le"
87 "test_encoding_mpeg4"
88 "test_encoding_mpeg1video"
89 "test_encoding_mp2"
90 "test_encoding_mjpeg"
91 "test_encoding_h264"
92 "test_encoding_dvvideo"
93 "test_encoding_dnxhd"
94 "test_encoding_aac"
95 "test_decoded_video_frame_count"
96 "test_decoded_time_base"
97 "test_decoded_motion_vectors"
98 "test_decode_half"
99 "test_decode_audio_sample_count"
100 "test_data"
101 "test_container_probing"
102 "test_codec_tag"
103 "test_selection"
104 ]
105 ++ lib.optionals (stdenv.isDarwin) [
106 # Segmentation Faults
107 "test_encoding_with_pts"
108 "test_bayer_write"
109 ];
110
111 disabledTestPaths = [
112 # urlopen fails during DNS resolution
113 "tests/test_doctests.py"
114 "tests/test_timeout.py"
115 ];
116
117 pythonImportsCheck = [
118 "av"
119 "av.audio"
120 "av.buffer"
121 "av.bytesource"
122 "av.codec"
123 "av.container"
124 "av._core"
125 "av.datasets"
126 "av.descriptor"
127 "av.dictionary"
128 "av.enum"
129 "av.error"
130 "av.filter"
131 "av.format"
132 "av.frame"
133 "av.logging"
134 "av.option"
135 "av.packet"
136 "av.plane"
137 "av.stream"
138 "av.subtitles"
139 "av.utils"
140 "av.video"
141 ];
142
143 meta = with lib; {
144 description = "Pythonic bindings for FFmpeg/Libav";
145 mainProgram = "pyav";
146 homepage = "https://github.com/mikeboers/PyAV/";
147 changelog = "https://github.com/PyAV-Org/PyAV/blob/v${version}/CHANGELOG.rst";
148 license = licenses.bsd2;
149 maintainers = with maintainers; [ ];
150 };
151}