Project

General

Profile

WIPVideo » History » Version 35

Saúl Ibarra Corretgé, 09/02/2014 05:09 PM

1 1 Saúl Ibarra Corretgé
h1. WIPVideo
2
3 5 Saúl Ibarra Corretgé
Notes while video is a work in progress. Repository: http://devel.ag-projects.com/cgi-bin/darcsweb.cgi?r=saul/python-sipsimple-video;a=summary
4 1 Saúl Ibarra Corretgé
5
h2. Dependencies
6
7
The following dependencies are required to build PJSIP with video support (including H264)
8
9
* ffmpeg (libavformat, libswscale, libavcodec, libavutil)
10
* libx264
11
12
Versions I have tried:
13
14
* ffmpeg (2.0 release)
15
* libx264 (snapshot-20130806-2245-stable)
16
17 20 Saúl Ibarra Corretgé
h2. Installing dependencies (Debian / Ubuntu systems)
18
19
The situation here is a bit sad. Both Debian and Ubuntu ship with libav instead of FFmpeg, but libraries are called the same. PJSIP had to be patched in order to properly work with libav, and the patch as not yet been included upstream.
20 1 Saúl Ibarra Corretgé
21 20 Saúl Ibarra Corretgé
On Debian, when the Debian-Multimedia repositories are used (quite common) you get FFmpeg and not libav. Oh the joy!
22
23
Installing dependencies on Debian:
24
25
<pre>
26 34 Saúl Ibarra Corretgé
apt-get install libv4l-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev libx264-dev libavcodec-extra
27 1 Saúl Ibarra Corretgé
</pre>
28 20 Saúl Ibarra Corretgé
29
If using the Debian-Multimedia repositories, do not install libavcodec-extra.
30
31
Installing dependencies on Ubuntu:
32
33
<pre>
34 34 Saúl Ibarra Corretgé
apt-get install libv4l-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev libx264-dev libavcodec-extra53
35 20 Saúl Ibarra Corretgé
</pre>
36 1 Saúl Ibarra Corretgé
37 20 Saúl Ibarra Corretgé
*Note on H.264 support*: In order to have H.264 support, FFmpeg (or libav) need to be compiled with support for it. The standard packages don't, hence the need for installing the libavcodec-extra packages.
38 21 Saúl Ibarra Corretgé
39 20 Saúl Ibarra Corretgé
h2. Compiling dependencies
40 3 Saúl Ibarra Corretgé
41
All dependencies will be compiled to a directory in the user's HOME directory:
42
43
<pre>
44 34 Saúl Ibarra Corretgé
export MY_FFMPEG_LIBS=$HOME/work/ag-projects/video/local
45 3 Saúl Ibarra Corretgé
</pre>
46
47
h3. libx264
48
49 35 Saúl Ibarra Corretgé
50 1 Saúl Ibarra Corretgé
<pre>
51 35 Saúl Ibarra Corretgé
./configure --enable-static --disable-avs --disable-lavf --disable-ffms --disable-gpac --prefix=$MY_FFMPEG_LIBS
52 3 Saúl Ibarra Corretgé
make
53 1 Saúl Ibarra Corretgé
make install
54 8 Saúl Ibarra Corretgé
55 35 Saúl Ibarra Corretgé
# If a 32bit build is wanted on OSX, then run this configure instead:
56
./configure --host=i386-apple-darwin --enable-static --disable-avs --disable-lavf --disable-ffms --disable-gpac --prefix=$MY_FFMPEG_LIBS
57 3 Saúl Ibarra Corretgé
</pre>
58
59 1 Saúl Ibarra Corretgé
h3. ffmpeg
60
61 3 Saúl Ibarra Corretgé
<pre>
62
# Some exports
63 35 Saúl Ibarra Corretgé
export PKG_CONFIG_PATH=$MY_FFMPEG_LIBS/lib/pkgconfig
64 3 Saúl Ibarra Corretgé
65 35 Saúl Ibarra Corretgé
./configure --enable-shared --disable-static --enable-memalign-hack --enable-gpl --enable-libx264 --prefix=$MY_FFMPEG_LIBS --extra-cflags="`pkg-config --cflags x264`" --extra-ldflags="`pkg-config --libs x264`"
66 1 Saúl Ibarra Corretgé
make
67
make install
68 9 Saúl Ibarra Corretgé
69 35 Saúl Ibarra Corretgé
# If a 32bit build is wanted on OSX do:
70
./configure --enable-shared --disable-static --enable-memalign-hack --enable-gpl --enable-libx264 --prefix=$MY_FFMPEG_LIBS --extra-cflags="`pkg-config --cflags x264`" --extra-ldflags="`pkg-config --libs x264`" --cc="gcc -m32"
71 4 Saúl Ibarra Corretgé
</pre>
72
73
h2. Proposed API
74 12 Saúl Ibarra Corretgé
75 34 Saúl Ibarra Corretgé
TODO: API changed, update this.
76
77 13 Saúl Ibarra Corretgé
API for video components is based on 2 different types of video capable entities:
78
79
* VideoProducer: a source for video data, for example a video camera or a remote video stream
80
* VideoConsumer: a sink or destination for video data, for example a video rendering window
81
82
h3. Data flow
83
84
Data flow works in _pull_ fashion, that is, a producer doesn't start to produce data until there is a consumer which will consume it.
85
86
h3. VideoProducer
87
88
Produces video data. 
89
90
Internal API:
91
92 1 Saúl Ibarra Corretgé
* _add_consumer: attach a consumer, called by the consumer
93 13 Saúl Ibarra Corretgé
* _remove_consumer: detach a consumer from a producer, called by the consumer
94
95
96 18 Saúl Ibarra Corretgé
Public API:
97 1 Saúl Ibarra Corretgé
98
* start: start producing video as soon as a consumer is attached
99 18 Saúl Ibarra Corretgé
* stop: immediately stop producing data
100
* close: remove all consumers and stop producing video data (also deallocate all C structures)
101 29 Saúl Ibarra Corretgé
* producer_port: pointer to the pjmedia_port object
102 14 Saúl Ibarra Corretgé
103
h3. VideoConsumer
104
105
Consumes video data.
106
107
Public API:
108
109
* producer: (r/w property) attach this consumer to a producer, in order to render the video data generated by the producer. If set to None, it's detached
110 24 Saúl Ibarra Corretgé
* consumer_port: pointer to the pjmedia_port object
111 14 Saúl Ibarra Corretgé
* close: detach from producer and free all resources (also deallocate all C structures)
112 30 Saúl Ibarra Corretgé
113 15 Saúl Ibarra Corretgé
h3. Producer and consumer objects
114
115
* VideoDevice: Producer, acquires video from a user camera.
116
* VideoWindow: Consumer, renders video in an SDL window. Extra methods: show/hide. Properties: native_handle, size.
117
118
* LocalVideoStream: Consumer, takes video from a VideoDevice and sends it to the remote party.
119
* RemoteVideoStream: Producer, produces video sent by the remote party.
120
121
These are just theoretical objects, won't be implemented in the first go.
122
123 17 Saúl Ibarra Corretgé
* VideoFileWriter: Consumer, saves incoming video data to a video file.
124 15 Saúl Ibarra Corretgé
* VideoFilePlayer: Producer, produces video data out of a video file.
125
126
* VideoMixer: Producer/Consumer, consumes video from multiple sources and produces aggregated video data.
127 16 Saúl Ibarra Corretgé
128 34 Saúl Ibarra Corretgé
NOTE: pjsip does have a AVI file player, which also seems to support audio. (this could be used to stream a movie, for example)
129 23 Saúl Ibarra Corretgé
130
h2. H264
131
132
Information about H264 profiles:
133
134
* http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels
135
* https://supportforums.cisco.com/blog/149561/video-telepresence-sip-h264-profile-level-id
136 28 Saúl Ibarra Corretgé
137
h2. OpenH264 implementation
138
139
PJSIP has an initial version of a wrapper for Cisco's OpenH264 implementation (http://www.openh264.org/). http://trac.pjsip.org/repos/changeset?reponame=&old=4815%40%2F&new=4815%40%2F
140
141
OpenH264 seems to implement SVC, which is better than AVC.