forked from PyAV-Org/PyAV
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhacking.html
More file actions
213 lines (203 loc) · 11.3 KB
/
Copy pathhacking.html
File metadata and controls
213 lines (203 loc) · 11.3 KB
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hacking on PyAV — PyAV 0.3.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.3.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="shortcut icon" href="_static/favicon.png"/>
<link rel="author" title="About these documents" href="about.html" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="PyAV 0.3.3 documentation" href="index.html" />
<link rel="next" title="Wrapped C Types and Functions" href="includes.html" />
<link rel="prev" title="API Reference" href="api.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="includes.html" title="Wrapped C Types and Functions"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="api.html" title="API Reference"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">PyAV 0.3.3 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="hacking-on-pyav">
<h1>Hacking on PyAV<a class="headerlink" href="#hacking-on-pyav" title="Permalink to this headline">¶</a></h1>
<div class="section" id="the-real-goal">
<h2>The Real Goal<a class="headerlink" href="#the-real-goal" title="Permalink to this headline">¶</a></h2>
<p>The goal here is to not only wrap ffmpeg in Python and provide nearly complete
access to the library, but to make it easier to use without the need to
understand the full library.</p>
<p>For example:</p>
<ul class="simple">
<li>we don’t need to mimick the underlying project structure as much as we do;</li>
<li>we shouldn’t be exposing audio attributes on a video codec, and vise-versa;</li>
<li>the concept of packets could be abtracted away to yielding frames from streams;</li>
<li>time should be a real number, instead of a rational;</li>
<li>...</li>
</ul>
</div>
<div class="section" id="ffmpeg-vs-libav">
<h2>FFmpeg vs Libav<a class="headerlink" href="#ffmpeg-vs-libav" title="Permalink to this headline">¶</a></h2>
<p>We test compile and link tiny executables to determine what functions and
structure members are availible, and some very small shim headers to smooth
out the differences.</p>
<p>We <a class="reference external" href="https://travis-ci.org/mikeboers/PyAV">continually test</a> multiple versions
of FFmpeg/Libav, as well as Linux/OS X, and Python 2/3.</p>
<p>You can use the same build system as Travis for local development:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">source</span> <span class="n">scripts</span><span class="o">/</span><span class="n">activate</span><span class="o">.</span><span class="n">sh</span> <span class="n">ffmpeg</span> <span class="mf">2.7</span>
<span class="o">./</span><span class="n">scripts</span><span class="o">/</span><span class="n">build</span><span class="o">-</span><span class="n">deps</span>
<span class="n">make</span>
<span class="n">nosetests</span>
</pre></div>
</div>
</div>
<div class="section" id="library-detection">
<h2>Library Detection<a class="headerlink" href="#library-detection" title="Permalink to this headline">¶</a></h2>
<p>Macros will be defined for the libraries we link against. In particular, you
will have either <code class="docutils literal"><span class="pre">PYAV_HAVE_LIBSWRESAMPLE</span></code> or <code class="docutils literal"><span class="pre">PYAV_HAVE_LIBAVRESAMPLE</span></code>.</p>
</div>
<div class="section" id="function-detection">
<h2>Function Detection<a class="headerlink" href="#function-detection" title="Permalink to this headline">¶</a></h2>
<p>Macros will be defined for a few functions that are only in one of FFmpeg or
LibAV. For example, there may be a <code class="docutils literal"><span class="pre">PYAV_HAVE_AVFORMAT_CLOSE_INPUT</span></code> macro.
See the <code class="docutils literal"><span class="pre">reflect</span></code> command in <code class="docutils literal"><span class="pre">setup.py</span></code> to add more.</p>
</div>
<div class="section" id="struct-member-detection">
<h2>Struct Member Detection<a class="headerlink" href="#struct-member-detection" title="Permalink to this headline">¶</a></h2>
<p>Macros will be defined for structure members that are not garunteed to exist
(usually because LibAV deprecated and removed them, while FFmpeg did not).
For example, there may be a <code class="docutils literal"><span class="pre">PYAV_HAVE_AVFRAME__MB_TYPE</span></code> macro if the
<code class="docutils literal"><span class="pre">AVFrame.mb_type</span></code> member exists.</p>
</div>
<div class="section" id="class-relationships">
<h2>Class Relationships<a class="headerlink" href="#class-relationships" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">Context.streams</span></code> is a list of <code class="docutils literal"><span class="pre">Stream</span></code>.</li>
<li><code class="docutils literal"><span class="pre">Packet.stream</span></code> is the <code class="docutils literal"><span class="pre">Stream</span></code> that it is from.</li>
<li><code class="docutils literal"><span class="pre">Frame</span></code> has no relationships in Python space.</li>
</ul>
</div>
<div class="section" id="time-in-libraries">
<h2>Time in Libraries<a class="headerlink" href="#time-in-libraries" title="Permalink to this headline">¶</a></h2>
<p>Time is usually represented as fractions; there is often a <code class="docutils literal"><span class="pre">uint64_t</span> <span class="pre">pts</span></code> or
<code class="docutils literal"><span class="pre">dts</span></code> variable in <cite>AVRational time_base</cite> units.</p>
<p>Both <code class="docutils literal"><span class="pre">AVStream</span></code> and <code class="docutils literal"><span class="pre">AVCodecContext</span></code> have a time_base. While encoding, they
are for the <code class="docutils literal"><span class="pre">AVPacket</span></code> and <code class="docutils literal"><span class="pre">AVFrame</span></code> times respectively. However, while
decoding all times are in <code class="docutils literal"><span class="pre">AVStream.time_base</span></code>.</p>
<dl class="docutils">
<dt>TODO: I have seen the decode time_base be different in the codec_context JPEG</dt>
<dd>sequence tests!</dd>
</dl>
<p>When there is no time_base (such as on <code class="docutils literal"><span class="pre">AVFormatContext</span></code>), there is an
implicit time_base of <code class="docutils literal"><span class="pre">1/AV_TIME_BASE</span></code>.</p>
</div>
<div class="section" id="debugging">
<h2>Debugging<a class="headerlink" href="#debugging" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal"><span class="pre">`</span>
<span class="pre">./configure</span> <span class="pre">--with-pydebug</span> <span class="pre">--with-pymalloc</span>
<span class="pre">make</span> <span class="pre">-j12</span>
<span class="pre">`</span></code></p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/logo-250.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Hacking on PyAV</a><ul>
<li><a class="reference internal" href="#the-real-goal">The Real Goal</a></li>
<li><a class="reference internal" href="#ffmpeg-vs-libav">FFmpeg vs Libav</a></li>
<li><a class="reference internal" href="#library-detection">Library Detection</a></li>
<li><a class="reference internal" href="#function-detection">Function Detection</a></li>
<li><a class="reference internal" href="#struct-member-detection">Struct Member Detection</a></li>
<li><a class="reference internal" href="#class-relationships">Class Relationships</a></li>
<li><a class="reference internal" href="#time-in-libraries">Time in Libraries</a></li>
<li><a class="reference internal" href="#debugging">Debugging</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="api.html"
title="previous chapter">API Reference</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="includes.html"
title="next chapter">Wrapped C Types and Functions</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/hacking.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="includes.html" title="Wrapped C Types and Functions"
>next</a> |</li>
<li class="right" >
<a href="api.html" title="API Reference"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">PyAV 0.3.3 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2017, Mike Boers.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9.
</div>
</body>
</html>