Last active
January 27, 2018 09:30
-
-
Save jdmichaud/021771059393b53073599e6bb5ac67f4 to your computer and use it in GitHub Desktop.
Compile gstreamer (ubuntu 16.04)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With the help of: | |
# https://github.com/video-dev/hls.js | |
# https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Live_streaming_web_audio_and_video | |
# https://gstreamer.freedesktop.org/documentation/frequently-asked-questions/using.html | |
Preconditions: | |
export DEST_PATH ... | |
export GS_VERSION=$GS_VERSION | |
For gstreamer: | |
bison | |
flex | |
libglib2.0-dev | |
For hls (in gstreamer-bad-plugins) | |
nettle-dev | |
For x264 (in gstreamer-ugly-plugins) | |
libx264-dev | |
mkdir -p $DEST_PATH | |
# Install and configure gstreamer | |
curl -sOL https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-$GS_VERSION.tar.xz | |
tar xf gstreamer-$GS_VERSION.tar.xz | |
cd gstreamer-$GS_VERSION/ | |
./configure --prefix=$DEST_DIR | |
make -j 4 | |
make install | |
export CPPFLAGS="-I$DEST_DIR/include/" | |
export LDFLAGS="-L$DEST_DIR/lib/" | |
export PKG_CONFIG_PATH=$DEST_DIR/lib/pkgconfig | |
# Install and configure gstreamer-base-plugins | |
curl -sOL https://gstreamer.freedesktop.org/src/gst-plugins-base/gst-plugins-base-$GS_VERSION.tar.xz | |
tar xf gst-plugins-base.$GS_VERSION.tar.xz | |
cd gst-plugins-base-$GS_VERSION/ | |
./configure --prefix=$DEST_DIR | |
# Install and condigure gstreamer-good-plugins | |
curl -sOL https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-$GS_VERSION.tar.xz | |
tar xf gst-plugins-good-$GS_VERSION.tar.xz | |
cd gst-plugins-good-$GS_VERSION/ | |
./configure --prefix=$DEST_DIR | |
make -j 4 | |
make install | |
# Install and condigure gstreamer-bad-plugins | |
curl -sOL https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-$GS_VERSION.tar.xz | |
tar xf gst-plugins-good-$GS_VERSION.tar.xz | |
cd gst-plugins-good-$GS_VERSION/ | |
./configure --prefix=$DEST_DIR | |
make -j 4 | |
make install | |
# Install and condigure gstreamer-ugly-plugins | |
curl -sOL https://gstreamer.freedesktop.org/src/gst-plugins-ugly/gst-plugins-bad-$GS_VERSION.tar.xz | |
tar xf gst-plugins-good-$GS_VERSION.tar.xz | |
cd gst-plugins-good-$GS_VERSION/ | |
./configure --prefix=$DEST_DIR | |
make -j 4 | |
make install | |
# Test with | |
$DEST_DIR/bin/gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink | |
# To broadcast a livestream: | |
# a. Create a tempopray folder | |
mkdir /tmp/test/ | |
cd /tmp/test/ | |
# b. Then create an index.html, we will be using hls.js | |
cat > index.html << EOF | |
<html> | |
<body> | |
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script> | |
<video id="video"></video> | |
<script> | |
if(Hls.isSupported()) { | |
var video = document.getElementById('video'); | |
var hls = new Hls(); | |
// playlist.m3u8 will be generated by gstreamer along with the segment files | |
hls.loadSource('http://localhost:8000/playlist.m3u8'); | |
hls.attachMedia(video); | |
hls.on(Hls.Events.MANIFEST_PARSED,function() { | |
video.play(); | |
}); | |
} else { | |
console.error('HLS is not supported by your browser'); | |
} | |
</script> | |
</body> | |
</html> | |
EOF | |
# c. Launch a simple http server in that folder | |
python -m SimpleHTTPServer | |
# d. Start broadcasting (/!\ In the same folder) | |
$DEST_DIR/bin/gst-launch-1.0 videotestsrc is-live=true ! x264enc ! mpegtsmux ! hlssink max-files=5 playlist-root=http://localhost:8000 | |
# e. Open a browser at http://localhost:8000 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment