Project

General

Profile

WIPVideo » History » Version 37

Saúl Ibarra Corretgé, 09/02/2014 06:21 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 36 Saúl Ibarra Corretgé
NOTE: yasm is required in order to enable asm optimizations. It does not come preinstalled on OSX, so it has to be manually installed. (brew install yasm will do)
48
49 3 Saúl Ibarra Corretgé
h3. libx264
50
51 35 Saúl Ibarra Corretgé
52 1 Saúl Ibarra Corretgé
<pre>
53 37 Saúl Ibarra Corretgé
./configure --enable-shared --disable-avs --disable-lavf --disable-ffms --disable-gpac --prefix=$MY_FFMPEG_LIBS
54 3 Saúl Ibarra Corretgé
make
55 1 Saúl Ibarra Corretgé
make install
56 8 Saúl Ibarra Corretgé
57 35 Saúl Ibarra Corretgé
# If a 32bit build is wanted on OSX, then run this configure instead:
58 37 Saúl Ibarra Corretgé
./configure --host=i386-apple-darwin --enable-shared --disable-avs --disable-lavf --disable-ffms --disable-gpac --prefix=$MY_FFMPEG_LIBS
59 3 Saúl Ibarra Corretgé
</pre>
60
61 1 Saúl Ibarra Corretgé
h3. ffmpeg
62
63 3 Saúl Ibarra Corretgé
<pre>
64
# Some exports
65 35 Saúl Ibarra Corretgé
export PKG_CONFIG_PATH=$MY_FFMPEG_LIBS/lib/pkgconfig
66 3 Saúl Ibarra Corretgé
67 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`"
68 1 Saúl Ibarra Corretgé
make
69
make install
70 9 Saúl Ibarra Corretgé
71 35 Saúl Ibarra Corretgé
# If a 32bit build is wanted on OSX do:
72
./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"
73 4 Saúl Ibarra Corretgé
</pre>
74
75
h2. Proposed API
76 12 Saúl Ibarra Corretgé
77 34 Saúl Ibarra Corretgé
TODO: API changed, update this.
78
79 13 Saúl Ibarra Corretgé
API for video components is based on 2 different types of video capable entities:
80
81
* VideoProducer: a source for video data, for example a video camera or a remote video stream
82
* VideoConsumer: a sink or destination for video data, for example a video rendering window
83
84
h3. Data flow
85
86
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.
87
88
h3. VideoProducer
89
90
Produces video data. 
91
92
Internal API:
93
94 1 Saúl Ibarra Corretgé
* _add_consumer: attach a consumer, called by the consumer
95 13 Saúl Ibarra Corretgé
* _remove_consumer: detach a consumer from a producer, called by the consumer
96
97
98 18 Saúl Ibarra Corretgé
Public API:
99 1 Saúl Ibarra Corretgé
100
* start: start producing video as soon as a consumer is attached
101 18 Saúl Ibarra Corretgé
* stop: immediately stop producing data
102
* close: remove all consumers and stop producing video data (also deallocate all C structures)
103 29 Saúl Ibarra Corretgé
* producer_port: pointer to the pjmedia_port object
104 14 Saúl Ibarra Corretgé
105
h3. VideoConsumer
106
107
Consumes video data.
108
109
Public API:
110
111
* 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
112 24 Saúl Ibarra Corretgé
* consumer_port: pointer to the pjmedia_port object
113 14 Saúl Ibarra Corretgé
* close: detach from producer and free all resources (also deallocate all C structures)
114 30 Saúl Ibarra Corretgé
115 15 Saúl Ibarra Corretgé
h3. Producer and consumer objects
116
117
* VideoDevice: Producer, acquires video from a user camera.
118
* VideoWindow: Consumer, renders video in an SDL window. Extra methods: show/hide. Properties: native_handle, size.
119
120
* LocalVideoStream: Consumer, takes video from a VideoDevice and sends it to the remote party.
121
* RemoteVideoStream: Producer, produces video sent by the remote party.
122
123
These are just theoretical objects, won't be implemented in the first go.
124
125 17 Saúl Ibarra Corretgé
* VideoFileWriter: Consumer, saves incoming video data to a video file.
126 15 Saúl Ibarra Corretgé
* VideoFilePlayer: Producer, produces video data out of a video file.
127
128
* VideoMixer: Producer/Consumer, consumes video from multiple sources and produces aggregated video data.
129 16 Saúl Ibarra Corretgé
130 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)
131 23 Saúl Ibarra Corretgé
132
h2. H264
133
134
Information about H264 profiles:
135
136
* http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels
137
* https://supportforums.cisco.com/blog/149561/video-telepresence-sip-h264-profile-level-id
138 28 Saúl Ibarra Corretgé
139
h2. OpenH264 implementation
140
141
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
142
143
OpenH264 seems to implement SVC, which is better than AVC.