SlideShare a Scribd company logo
Live Streaming in Android
Ahmet Oğuz Mermerkaya
Software Developer
Aselsan
@mekya84
ahmetmermerkaya@gmail.com
*
Ahmet Oğuz Mermerkaya
● Writer of an Android Application Programming book,
Merhaba Android, in Turkish
● Member of GDG Ankara
● Software Developer in Aselsan, Defense Industry
Company in Turkiye
*
Outline
● How live streaming works
● Building FFmpeg(with x264 and fdk-aac)
● Using Vitamio MediaPlayer
● Implementing a RTSP Server
● Sending Previews and Audio From RTSP Server
● Receiving and Playing Audio On Client
*
How live streaming works
● RTSP (Real Time Streaming Protocol)
● RTP (Real Time Protocol)
*
How live streaming works
● RTSP (Real Time Streaming Protocol)
● RTP (Real Time Protocol)
This is the
part FFmpeg
takes place
*
What is FFmpeg?
● Open-source, cross-platform multimedia framework
● Supports almost all codecs and formats(H264, H263,
AAC, AMR, MP4, MP3, AVI)
● Streams Audio and Video
ffmpeg.org
*
Building FFmpeg
● Download
o FFmpeg (http://fmpeg.org)
o fdk_aac for using AAC encoder
(http://sourceforge.net/projects/opencore-amr/files/fdk-aac/)
o libx264 source code for H264 encoder
(http://www.videolan.org/developers/x264.html)
o Android NDK for cross compiling(http://developer.android.com)
● Configure & Make
*
Building FFmpeg - Configure & Make
export PATH=ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:$PATH
#libx264
./configure --cross-prefix=arm-linux-androideabi- enable-pic --disable-cli -enable-static --disable-shared -
-host=arm-linux --extra-cflags="-march=armv7-a -mfloat-abi=softfp" --sysroot=/path/to/android-
ndk/platforms/android-87arch-arm/
make
#fdk-aac
./configure --host=arm-android-eabi-linux --enable-static --prefix=/path/to/fdk-aac/ --disable-shared
make
#ffmpeg
./configure --disable-everything --enable-gpl --enable-libx264 --enable-libfdk-aac --enable-nonfree --
enable-pthreads --cross-prefix=arm-linux-androideabi- --arch=arm --sysroot=/path/to/android-
ndk/platforms/android-8/arch/arm/ --extra-cflags="-march=armv7-a -mfloat-abi=softfp" --extra-cflags="-
I./x264" --extra-cflags="-I./fdk-aac/include/" --extra-ldflags="-L./x264" --extra-ldflags="-L./fdk-aac/lib"
--datadir="/data/ffmpeg/bin/ffpresets" --enable-version3 --enable-decoder=rawvideo --enable-demuxer=rawvideo
--enable-decoder=aarc --enable-demuxer=aac --enable-muxer=h264 --enable-encoder=pcm_s16le --enable-
protocol=rtp --enable-protocol=udp --enable-muxer?rtp --enable-demuxer=image2pipe --enable-muzer=adts --
enable-muxer=pcm_s16le --enable-demuxer=pcm_s16le --enable-demuxer=h264 --enable-filter=scale --enable-
encoder=libx264 --enable-encoder=libfdk_aac -enable-protocol=pipe --enable-decoder=pcm_s16le --enable-
filter=aresample
make
*
Using Vitamio Player
● Get it from vitamio.org and extract
Line 1 VideoView videoView = (VideoView) findViewById(R.id.videoView);
Line 2 videoView.setVideoPath("rtsp://IP_OF_ANDROID_STREAM_SERVER:PORT/live.ts");
● To start vitamio play with partial buffer, follow the instructions on http://vitamio.org/topics/104?locale=en
Then we need a RTSP server
*
Implementing a RTSP Server
Client (MediaPlayer - Vitamio) RTSP Server
*
Sending Previews From RTSP Server
Line 1 public void startVideo(String address, int port) {
Line 2 String videoCommand = "path/to/ffmpeg -analyzeduration 0 -pix_fmt nv21
Line 3 -s 480x360 -vcodec rawvideo -f image2pipe -i - -s 320x240 -crf
18
Line 4 -preset ultrafast -vcodec libx264 -f rtp
rtp://"+address+":"+port;
Line 5 Process ffmpegVideoProcess = Runtime.getRuntime().exec(videoCommand);
Line 6 OutputStream ostream = ffmpegVideoProcess.getOutputStream();
Line 7
Line 8 getCamera().setPreviewCallback(new PreviewCallback(){
Line 9 public void onPreviewFrame(byte[] buffer, Camera cam) {
Line 10 ostream.write(buffer);
Line 11 ostream.flush();
Line 12 }
Line 13 });
Line 14 }
*
Sending Audio From RTSP Server
Line 1 public void startAudio(String address, int port) {
Line 2 String audioCommand = "path/to/ffmpeg -analyzeduration 0 -f s16le -ac
Line 3 44100 -ac 1 -i - -ac 1 -acodec libfdk_aac -f adts -vbr
3
Line 4 udp://"+address+ ":" + port +"/";
Line 5 Process ffmpegAudioProcess = Runtime.getRuntime().exec(audioCommand);
Line 6 OutputStream ostream = ffmpegAudioProcess.getOutputStream();
Line 7 prepareAudioRecord();
Line 8 new Thread(){ public void run(){
Line 9 while(true) {
Line 10 int len = audioRecord.read(audioBuffer, 0,
audioBuffer.length);
Line 11 ostream.write(audioBuffer, 0, len);
Line 12 ostream.flush()
Line 13 }
Line 14 }}.start();
*
Receiving Audio On Client
Line 1 public void receiveAudio() {
Line 2 String audioCommand = "path/to/ffmpeg -analyzeduration 0 -f aac -strict -2 -
acodec
Line 3 aac -b:a 120k -ac 1 -i - -ac 1 -acodec pcm_s16le -ar 44100 -f s16le -";
Line 5 Process ffmpegAudioProcess = Runtime.getRuntime().exec(audioCommand);
Line 6 OutputStream ostream = ffmpegAudioProcess.getOutputStream();
Line 7 DatagramSocket udpsocket = new DatagramSocket(PORT);
Line 8 DatagramPacket packet = new DatagramPacket(new byte[2048], 2048);
Line 9 new Thread(){ public void run(){
while(true) {
Line 10 udpsocket.receive(packet);
Line 11 ostream.write(datagramPacket.getData(), 0,
datagram.getLength());
Line 12 ostream.flush();
Line 13 }}}.start();
*
Playing Audio On Client
Line 1 public void playAudio(final InputStream istream) {
Line 2 byte[] buffer = new byte[2048];
Line 3 int bufferSize = AudioTrack.getMinBufferSize(44100,...);
Line 5 audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,44100,
Line 6 AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT,
Line 7 bufferSize, AudioTrack.MODE_STREAM);
Line 8 audioTrack.play();
Line 9 while (true) {
Line 10 int len = istream.read(buffer, 0, buffer.length);
Line 11 audioTrack.write(buffer, 0, len);
Line 12 audioTrack.flush()
Line 13 }
Line 14 }
Demo
*
Android Developer Days
● Expected 1500~ participants
● Partner of Droidcon.com
● 15 co-organizers from 7 countries
● Free of charge
● This year more inspiration, more
networking and more fun
● ADD 2012 web site ->
www.androiddeveloperdays.com/2012
Date: June 14, 15 2013
Venue: METU, Ankara, Turkiye
www.androiddeveloperdays.com
Thank you for listening
Live Streaming in Android
Ahmet Oğuz Mermerkaya
@mekya84
ahmetmermerkaya@gmail.com

More Related Content

What's hot

Audio and Video streaming.ppt
Audio and Video streaming.pptAudio and Video streaming.ppt
Audio and Video streaming.ppt
Videoguy
 
Mag 322 w1 iptv set top box - newtech.co.uk
Mag 322 w1 iptv set top box - newtech.co.ukMag 322 w1 iptv set top box - newtech.co.uk
Mag 322 w1 iptv set top box - newtech.co.uk
Newtech Store Limited
 
Streaming Video Techniques
Streaming Video TechniquesStreaming Video Techniques
Streaming Video Techniques
Arumai Technologies, Inc.
 
【Specification】Geniatech Atv1960 AmLogic S912 Octa-core Android TV Box Comes ...
【Specification】Geniatech Atv1960 AmLogic S912 Octa-core Android TV Box Comes ...【Specification】Geniatech Atv1960 AmLogic S912 Octa-core Android TV Box Comes ...
【Specification】Geniatech Atv1960 AmLogic S912 Octa-core Android TV Box Comes ...
Geniatech
 
STATUS UPDATE OF COLO PROJECT XIAOWEI YANG, HUAWEI AND WILL AULD, INTEL
STATUS UPDATE OF COLO PROJECT XIAOWEI YANG, HUAWEI AND WILL AULD, INTELSTATUS UPDATE OF COLO PROJECT XIAOWEI YANG, HUAWEI AND WILL AULD, INTEL
STATUS UPDATE OF COLO PROJECT XIAOWEI YANG, HUAWEI AND WILL AULD, INTEL
The Linux Foundation
 
Audio and video streaming
Audio and video streamingAudio and video streaming
Audio and video streaming
Rohan Bhatkar
 
Mips track a
Mips   track aMips   track a
Mips track a
Alona Gradman
 
Live Streaming from A-Z
Live Streaming from A-ZLive Streaming from A-Z
Live Streaming from A-Z
Brightcove
 
Streaming Overview Final.ppt
Streaming Overview Final.pptStreaming Overview Final.ppt
Streaming Overview Final.ppt
Videoguy
 
At 0408 v-h9d-hybrid-video-recorder
At 0408 v-h9d-hybrid-video-recorderAt 0408 v-h9d-hybrid-video-recorder
At 0408 v-h9d-hybrid-video-recorder
Security System Mart.com
 
Issues of added_ip_devices
Issues of added_ip_devicesIssues of added_ip_devices
Issues of added_ip_devices
TSOLUTIONS
 
XPDS13: Performance Optimization on Xen-based Android Device - Jack Ren, Inte...
XPDS13: Performance Optimization on Xen-based Android Device - Jack Ren, Inte...XPDS13: Performance Optimization on Xen-based Android Device - Jack Ren, Inte...
XPDS13: Performance Optimization on Xen-based Android Device - Jack Ren, Inte...
The Linux Foundation
 
Video and Audio Streaming
Video and Audio StreamingVideo and Audio Streaming
Video and Audio Streaming
Karthick Kumar
 
SR-IOV, KVM and Intel X520 10Gbps cards on Debian/Stable
SR-IOV, KVM and Intel X520 10Gbps cards on Debian/StableSR-IOV, KVM and Intel X520 10Gbps cards on Debian/Stable
SR-IOV, KVM and Intel X520 10Gbps cards on Debian/Stable
juet-y
 
Embedded Recipes 2019 - RT is about to make it to mainline. Now what?
Embedded Recipes 2019 - RT is about to make it to mainline. Now what?Embedded Recipes 2019 - RT is about to make it to mainline. Now what?
Embedded Recipes 2019 - RT is about to make it to mainline. Now what?
Anne Nicolas
 
H 264 Pc Based Dvr
H 264 Pc Based DvrH 264 Pc Based Dvr
H 264 Pc Based Dvr
andy
 
vPoint HD briefing.ppt
vPoint HD briefing.pptvPoint HD briefing.ppt
vPoint HD briefing.ppt
Videoguy
 
Embedded Recipes 2018 - SoC+FPGA update in 2018 - Marek Vasut
Embedded Recipes 2018 - SoC+FPGA update in 2018 - Marek VasutEmbedded Recipes 2018 - SoC+FPGA update in 2018 - Marek Vasut
Embedded Recipes 2018 - SoC+FPGA update in 2018 - Marek Vasut
Anne Nicolas
 

What's hot (18)

Audio and Video streaming.ppt
Audio and Video streaming.pptAudio and Video streaming.ppt
Audio and Video streaming.ppt
 
Mag 322 w1 iptv set top box - newtech.co.uk
Mag 322 w1 iptv set top box - newtech.co.ukMag 322 w1 iptv set top box - newtech.co.uk
Mag 322 w1 iptv set top box - newtech.co.uk
 
Streaming Video Techniques
Streaming Video TechniquesStreaming Video Techniques
Streaming Video Techniques
 
【Specification】Geniatech Atv1960 AmLogic S912 Octa-core Android TV Box Comes ...
【Specification】Geniatech Atv1960 AmLogic S912 Octa-core Android TV Box Comes ...【Specification】Geniatech Atv1960 AmLogic S912 Octa-core Android TV Box Comes ...
【Specification】Geniatech Atv1960 AmLogic S912 Octa-core Android TV Box Comes ...
 
STATUS UPDATE OF COLO PROJECT XIAOWEI YANG, HUAWEI AND WILL AULD, INTEL
STATUS UPDATE OF COLO PROJECT XIAOWEI YANG, HUAWEI AND WILL AULD, INTELSTATUS UPDATE OF COLO PROJECT XIAOWEI YANG, HUAWEI AND WILL AULD, INTEL
STATUS UPDATE OF COLO PROJECT XIAOWEI YANG, HUAWEI AND WILL AULD, INTEL
 
Audio and video streaming
Audio and video streamingAudio and video streaming
Audio and video streaming
 
Mips track a
Mips   track aMips   track a
Mips track a
 
Live Streaming from A-Z
Live Streaming from A-ZLive Streaming from A-Z
Live Streaming from A-Z
 
Streaming Overview Final.ppt
Streaming Overview Final.pptStreaming Overview Final.ppt
Streaming Overview Final.ppt
 
At 0408 v-h9d-hybrid-video-recorder
At 0408 v-h9d-hybrid-video-recorderAt 0408 v-h9d-hybrid-video-recorder
At 0408 v-h9d-hybrid-video-recorder
 
Issues of added_ip_devices
Issues of added_ip_devicesIssues of added_ip_devices
Issues of added_ip_devices
 
XPDS13: Performance Optimization on Xen-based Android Device - Jack Ren, Inte...
XPDS13: Performance Optimization on Xen-based Android Device - Jack Ren, Inte...XPDS13: Performance Optimization on Xen-based Android Device - Jack Ren, Inte...
XPDS13: Performance Optimization on Xen-based Android Device - Jack Ren, Inte...
 
Video and Audio Streaming
Video and Audio StreamingVideo and Audio Streaming
Video and Audio Streaming
 
SR-IOV, KVM and Intel X520 10Gbps cards on Debian/Stable
SR-IOV, KVM and Intel X520 10Gbps cards on Debian/StableSR-IOV, KVM and Intel X520 10Gbps cards on Debian/Stable
SR-IOV, KVM and Intel X520 10Gbps cards on Debian/Stable
 
Embedded Recipes 2019 - RT is about to make it to mainline. Now what?
Embedded Recipes 2019 - RT is about to make it to mainline. Now what?Embedded Recipes 2019 - RT is about to make it to mainline. Now what?
Embedded Recipes 2019 - RT is about to make it to mainline. Now what?
 
H 264 Pc Based Dvr
H 264 Pc Based DvrH 264 Pc Based Dvr
H 264 Pc Based Dvr
 
vPoint HD briefing.ppt
vPoint HD briefing.pptvPoint HD briefing.ppt
vPoint HD briefing.ppt
 
Embedded Recipes 2018 - SoC+FPGA update in 2018 - Marek Vasut
Embedded Recipes 2018 - SoC+FPGA update in 2018 - Marek VasutEmbedded Recipes 2018 - SoC+FPGA update in 2018 - Marek Vasut
Embedded Recipes 2018 - SoC+FPGA update in 2018 - Marek Vasut
 

Similar to Live streaming in Android

2015.7.17 JANOG36 BGP Flowspec Interoperability Test @ Interop Tokyo 2015 Sho...
2015.7.17 JANOG36 BGP Flowspec Interoperability Test @ Interop Tokyo 2015 Sho...2015.7.17 JANOG36 BGP Flowspec Interoperability Test @ Interop Tokyo 2015 Sho...
2015.7.17 JANOG36 BGP Flowspec Interoperability Test @ Interop Tokyo 2015 Sho...
Shuichi Ohkubo
 
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PROIDEA
 
Gameboy emulator in rust and web assembly
Gameboy emulator in rust and web assemblyGameboy emulator in rust and web assembly
Gameboy emulator in rust and web assembly
Yodalee
 
RTSP Protocol - Explanation to develop API of RTSP Protocol
RTSP Protocol - Explanation to develop API of RTSP ProtocolRTSP Protocol - Explanation to develop API of RTSP Protocol
RTSP Protocol - Explanation to develop API of RTSP Protocol
FranZEast
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewHKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting Review
Linaro
 
Robotix Tutorial 9
Robotix Tutorial 9Robotix Tutorial 9
Robotix Tutorial 9
ankuredkie
 
Asa pixfwsm multicast tips and common problems
Asa pixfwsm multicast tips and common problemsAsa pixfwsm multicast tips and common problems
Asa pixfwsm multicast tips and common problems
IT Tech
 
Setup VoIP System and Interconnection with LTE network
Setup VoIP System and Interconnection with LTE networkSetup VoIP System and Interconnection with LTE network
Setup VoIP System and Interconnection with LTE network
Nazmul Hossain Rakib
 
Howto ethereal-wireshark-trace en
Howto ethereal-wireshark-trace enHowto ethereal-wireshark-trace en
Howto ethereal-wireshark-trace en
JORGE GOMEZ
 
Talk@JanusCon2019: Janus, WebRTC and ML - Fantastic technologies and how to m...
Talk@JanusCon2019: Janus, WebRTC and ML - Fantastic technologies and how to m...Talk@JanusCon2019: Janus, WebRTC and ML - Fantastic technologies and how to m...
Talk@JanusCon2019: Janus, WebRTC and ML - Fantastic technologies and how to m...
Paolo Saviano
 
Network Docs
Network DocsNetwork Docs
Network Docs
Sify Technologies
 
managing your network environment
managing your network environmentmanaging your network environment
managing your network environment
scooby_doo
 
Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015
Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015
Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015
Codemotion
 
BIRD Routing Daemon
BIRD Routing DaemonBIRD Routing Daemon
BIRD Routing Daemon
APNIC
 
Live Streaming with Receiver-based Peer-division Multiplexing
Live Streaming with Receiver-based Peer-division Multiplexing Live Streaming with Receiver-based Peer-division Multiplexing
Live Streaming with Receiver-based Peer-division Multiplexing
Vamsi IV
 
netLec5.pdf
netLec5.pdfnetLec5.pdf
netLec5.pdf
MuthuramanElangovan
 
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SPKrzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
PROIDEA
 
PLNOG15: VidMon - monitoring video signal quality in Service Provider IP netw...
PLNOG15: VidMon - monitoring video signal quality in Service Provider IP netw...PLNOG15: VidMon - monitoring video signal quality in Service Provider IP netw...
PLNOG15: VidMon - monitoring video signal quality in Service Provider IP netw...
PROIDEA
 
Hexapod ppt
Hexapod pptHexapod ppt
Hexapod ppt
shiv kumar rai
 
HTTP and 5G (fixed1)
HTTP and 5G (fixed1)HTTP and 5G (fixed1)
HTTP and 5G (fixed1)
dynamis
 

Similar to Live streaming in Android (20)

2015.7.17 JANOG36 BGP Flowspec Interoperability Test @ Interop Tokyo 2015 Sho...
2015.7.17 JANOG36 BGP Flowspec Interoperability Test @ Interop Tokyo 2015 Sho...2015.7.17 JANOG36 BGP Flowspec Interoperability Test @ Interop Tokyo 2015 Sho...
2015.7.17 JANOG36 BGP Flowspec Interoperability Test @ Interop Tokyo 2015 Sho...
 
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
 
Gameboy emulator in rust and web assembly
Gameboy emulator in rust and web assemblyGameboy emulator in rust and web assembly
Gameboy emulator in rust and web assembly
 
RTSP Protocol - Explanation to develop API of RTSP Protocol
RTSP Protocol - Explanation to develop API of RTSP ProtocolRTSP Protocol - Explanation to develop API of RTSP Protocol
RTSP Protocol - Explanation to develop API of RTSP Protocol
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewHKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting Review
 
Robotix Tutorial 9
Robotix Tutorial 9Robotix Tutorial 9
Robotix Tutorial 9
 
Asa pixfwsm multicast tips and common problems
Asa pixfwsm multicast tips and common problemsAsa pixfwsm multicast tips and common problems
Asa pixfwsm multicast tips and common problems
 
Setup VoIP System and Interconnection with LTE network
Setup VoIP System and Interconnection with LTE networkSetup VoIP System and Interconnection with LTE network
Setup VoIP System and Interconnection with LTE network
 
Howto ethereal-wireshark-trace en
Howto ethereal-wireshark-trace enHowto ethereal-wireshark-trace en
Howto ethereal-wireshark-trace en
 
Talk@JanusCon2019: Janus, WebRTC and ML - Fantastic technologies and how to m...
Talk@JanusCon2019: Janus, WebRTC and ML - Fantastic technologies and how to m...Talk@JanusCon2019: Janus, WebRTC and ML - Fantastic technologies and how to m...
Talk@JanusCon2019: Janus, WebRTC and ML - Fantastic technologies and how to m...
 
Network Docs
Network DocsNetwork Docs
Network Docs
 
managing your network environment
managing your network environmentmanaging your network environment
managing your network environment
 
Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015
Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015
Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015
 
BIRD Routing Daemon
BIRD Routing DaemonBIRD Routing Daemon
BIRD Routing Daemon
 
Live Streaming with Receiver-based Peer-division Multiplexing
Live Streaming with Receiver-based Peer-division Multiplexing Live Streaming with Receiver-based Peer-division Multiplexing
Live Streaming with Receiver-based Peer-division Multiplexing
 
netLec5.pdf
netLec5.pdfnetLec5.pdf
netLec5.pdf
 
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SPKrzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
 
PLNOG15: VidMon - monitoring video signal quality in Service Provider IP netw...
PLNOG15: VidMon - monitoring video signal quality in Service Provider IP netw...PLNOG15: VidMon - monitoring video signal quality in Service Provider IP netw...
PLNOG15: VidMon - monitoring video signal quality in Service Provider IP netw...
 
Hexapod ppt
Hexapod pptHexapod ppt
Hexapod ppt
 
HTTP and 5G (fixed1)
HTTP and 5G (fixed1)HTTP and 5G (fixed1)
HTTP and 5G (fixed1)
 

Recently uploaded

Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
alowpalsadig
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
sandeepmenon62
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
Reetu63
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
campbellclarkson
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
Envertis Software Solutions
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
Paul Brebner
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 

Recently uploaded (20)

Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 

Live streaming in Android

  • 1.
  • 2. Live Streaming in Android Ahmet Oğuz Mermerkaya Software Developer Aselsan @mekya84 ahmetmermerkaya@gmail.com
  • 3. * Ahmet Oğuz Mermerkaya ● Writer of an Android Application Programming book, Merhaba Android, in Turkish ● Member of GDG Ankara ● Software Developer in Aselsan, Defense Industry Company in Turkiye
  • 4. * Outline ● How live streaming works ● Building FFmpeg(with x264 and fdk-aac) ● Using Vitamio MediaPlayer ● Implementing a RTSP Server ● Sending Previews and Audio From RTSP Server ● Receiving and Playing Audio On Client
  • 5. * How live streaming works ● RTSP (Real Time Streaming Protocol) ● RTP (Real Time Protocol)
  • 6. * How live streaming works ● RTSP (Real Time Streaming Protocol) ● RTP (Real Time Protocol) This is the part FFmpeg takes place
  • 7. * What is FFmpeg? ● Open-source, cross-platform multimedia framework ● Supports almost all codecs and formats(H264, H263, AAC, AMR, MP4, MP3, AVI) ● Streams Audio and Video ffmpeg.org
  • 8. * Building FFmpeg ● Download o FFmpeg (http://fmpeg.org) o fdk_aac for using AAC encoder (http://sourceforge.net/projects/opencore-amr/files/fdk-aac/) o libx264 source code for H264 encoder (http://www.videolan.org/developers/x264.html) o Android NDK for cross compiling(http://developer.android.com) ● Configure & Make
  • 9. * Building FFmpeg - Configure & Make export PATH=ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:$PATH #libx264 ./configure --cross-prefix=arm-linux-androideabi- enable-pic --disable-cli -enable-static --disable-shared - -host=arm-linux --extra-cflags="-march=armv7-a -mfloat-abi=softfp" --sysroot=/path/to/android- ndk/platforms/android-87arch-arm/ make #fdk-aac ./configure --host=arm-android-eabi-linux --enable-static --prefix=/path/to/fdk-aac/ --disable-shared make #ffmpeg ./configure --disable-everything --enable-gpl --enable-libx264 --enable-libfdk-aac --enable-nonfree -- enable-pthreads --cross-prefix=arm-linux-androideabi- --arch=arm --sysroot=/path/to/android- ndk/platforms/android-8/arch/arm/ --extra-cflags="-march=armv7-a -mfloat-abi=softfp" --extra-cflags="- I./x264" --extra-cflags="-I./fdk-aac/include/" --extra-ldflags="-L./x264" --extra-ldflags="-L./fdk-aac/lib" --datadir="/data/ffmpeg/bin/ffpresets" --enable-version3 --enable-decoder=rawvideo --enable-demuxer=rawvideo --enable-decoder=aarc --enable-demuxer=aac --enable-muxer=h264 --enable-encoder=pcm_s16le --enable- protocol=rtp --enable-protocol=udp --enable-muxer?rtp --enable-demuxer=image2pipe --enable-muzer=adts -- enable-muxer=pcm_s16le --enable-demuxer=pcm_s16le --enable-demuxer=h264 --enable-filter=scale --enable- encoder=libx264 --enable-encoder=libfdk_aac -enable-protocol=pipe --enable-decoder=pcm_s16le --enable- filter=aresample make
  • 10. * Using Vitamio Player ● Get it from vitamio.org and extract Line 1 VideoView videoView = (VideoView) findViewById(R.id.videoView); Line 2 videoView.setVideoPath("rtsp://IP_OF_ANDROID_STREAM_SERVER:PORT/live.ts"); ● To start vitamio play with partial buffer, follow the instructions on http://vitamio.org/topics/104?locale=en Then we need a RTSP server
  • 11. * Implementing a RTSP Server Client (MediaPlayer - Vitamio) RTSP Server
  • 12. * Sending Previews From RTSP Server Line 1 public void startVideo(String address, int port) { Line 2 String videoCommand = "path/to/ffmpeg -analyzeduration 0 -pix_fmt nv21 Line 3 -s 480x360 -vcodec rawvideo -f image2pipe -i - -s 320x240 -crf 18 Line 4 -preset ultrafast -vcodec libx264 -f rtp rtp://"+address+":"+port; Line 5 Process ffmpegVideoProcess = Runtime.getRuntime().exec(videoCommand); Line 6 OutputStream ostream = ffmpegVideoProcess.getOutputStream(); Line 7 Line 8 getCamera().setPreviewCallback(new PreviewCallback(){ Line 9 public void onPreviewFrame(byte[] buffer, Camera cam) { Line 10 ostream.write(buffer); Line 11 ostream.flush(); Line 12 } Line 13 }); Line 14 }
  • 13. * Sending Audio From RTSP Server Line 1 public void startAudio(String address, int port) { Line 2 String audioCommand = "path/to/ffmpeg -analyzeduration 0 -f s16le -ac Line 3 44100 -ac 1 -i - -ac 1 -acodec libfdk_aac -f adts -vbr 3 Line 4 udp://"+address+ ":" + port +"/"; Line 5 Process ffmpegAudioProcess = Runtime.getRuntime().exec(audioCommand); Line 6 OutputStream ostream = ffmpegAudioProcess.getOutputStream(); Line 7 prepareAudioRecord(); Line 8 new Thread(){ public void run(){ Line 9 while(true) { Line 10 int len = audioRecord.read(audioBuffer, 0, audioBuffer.length); Line 11 ostream.write(audioBuffer, 0, len); Line 12 ostream.flush() Line 13 } Line 14 }}.start();
  • 14. * Receiving Audio On Client Line 1 public void receiveAudio() { Line 2 String audioCommand = "path/to/ffmpeg -analyzeduration 0 -f aac -strict -2 - acodec Line 3 aac -b:a 120k -ac 1 -i - -ac 1 -acodec pcm_s16le -ar 44100 -f s16le -"; Line 5 Process ffmpegAudioProcess = Runtime.getRuntime().exec(audioCommand); Line 6 OutputStream ostream = ffmpegAudioProcess.getOutputStream(); Line 7 DatagramSocket udpsocket = new DatagramSocket(PORT); Line 8 DatagramPacket packet = new DatagramPacket(new byte[2048], 2048); Line 9 new Thread(){ public void run(){ while(true) { Line 10 udpsocket.receive(packet); Line 11 ostream.write(datagramPacket.getData(), 0, datagram.getLength()); Line 12 ostream.flush(); Line 13 }}}.start();
  • 15. * Playing Audio On Client Line 1 public void playAudio(final InputStream istream) { Line 2 byte[] buffer = new byte[2048]; Line 3 int bufferSize = AudioTrack.getMinBufferSize(44100,...); Line 5 audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,44100, Line 6 AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, Line 7 bufferSize, AudioTrack.MODE_STREAM); Line 8 audioTrack.play(); Line 9 while (true) { Line 10 int len = istream.read(buffer, 0, buffer.length); Line 11 audioTrack.write(buffer, 0, len); Line 12 audioTrack.flush() Line 13 } Line 14 }
  • 16. Demo
  • 17. * Android Developer Days ● Expected 1500~ participants ● Partner of Droidcon.com ● 15 co-organizers from 7 countries ● Free of charge ● This year more inspiration, more networking and more fun ● ADD 2012 web site -> www.androiddeveloperdays.com/2012 Date: June 14, 15 2013 Venue: METU, Ankara, Turkiye www.androiddeveloperdays.com
  • 18. Thank you for listening Live Streaming in Android Ahmet Oğuz Mermerkaya @mekya84 ahmetmermerkaya@gmail.com