{"id":1838,"date":"2013-01-16T16:41:17","date_gmt":"2013-01-16T21:41:17","guid":{"rendered":"http:\/\/www.walking-productions.com\/notslop\/?p=1838"},"modified":"2013-01-16T16:41:17","modified_gmt":"2013-01-16T21:41:17","slug":"android-live-streaming-courtesy-of-javacv-and-ffmpeg","status":"publish","type":"post","link":"https:\/\/www.walking-productions.com\/notslop\/2013\/01\/16\/android-live-streaming-courtesy-of-javacv-and-ffmpeg\/","title":{"rendered":"Android Live Streaming courtesy of JavaCV and FFMPEG"},"content":{"rendered":"<p>For the last little or should I say, long while I have been working on wrangling a solution for live streaming from Android that is both decent quality and extensible.  For those of you interested, the litter in <a href=\"https:\/\/github.com\/vanevery\/\">my GitHub account<\/a> documents various previous attempts.<\/p>\n<p>As far as I can tell, most folks that are streaming live video from Android are relying upon the video captured by the MediaRecorder and underlying classes and doing a bit of trickery with the file either while it sent to the server or on the server for distribution.  This is fine but it doesn&#8217;t give hooks into the actual video frames before they are encoded and sent over the network. <\/p>\n<p>Recently, I came across Samuel Audet&#8217;s amazing open source <a href=\"https:\/\/code.google.com\/p\/javacv\/\">JavaCV project<\/a>.  In that project Samuel is wrapping FFMPEG&#8217;s underlying libraries (avcodec, avformat, and so on) using his equally amazing JavaCPP project to expose their functionality to any Java application.<\/p>\n<p>Finally, after a few weeks of experimentation and little (actually a LOT) of help from Samuel himself, I have something working!<\/p>\n<figure id=\"attachment_1840\" aria-describedby=\"caption-attachment-1840\" style=\"width: 225px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151758.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151758-e1358371877426-225x300.jpg\" alt=\"Running the live streaming app on a Galaxy Camera\" title=\"App on Phone\/Camera\" width=\"225\" height=\"300\" class=\"size-medium wp-image-1840\" srcset=\"https:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151758-e1358371877426-225x300.jpg 225w, https:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151758-e1358371877426-768x1024.jpg 768w, https:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151758-e1358371877426.jpg 1920w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><figcaption id=\"caption-attachment-1840\" class=\"wp-caption-text\">Running the live streaming app on a Galaxy Camera<\/figcaption><\/figure>\n<p><a href=\"http:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151803.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151803-300x225.jpg\" alt=\"\" title=\"App running on the phone\/camera\" width=\"300\" height=\"225\" class=\"alignleft size-medium wp-image-1841\" srcset=\"https:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151803-300x225.jpg 300w, https:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151803-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<figure id=\"attachment_1842\" aria-describedby=\"caption-attachment-1842\" style=\"width: 300px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151824.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151824-300x225.jpg\" alt=\"\" title=\"App and resulting stream on computer\" width=\"300\" height=\"225\" class=\"size-medium wp-image-1842\" srcset=\"https:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151824-300x225.jpg 300w, https:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151824-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1842\" class=\"wp-caption-text\">App and resulting stream on desktop via Wowza Media Server and Flash<\/figcaption><\/figure>\n<p><a href=\"http:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151839.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151839-300x225.jpg\" alt=\"\" title=\"App and resulting stream\" width=\"300\" height=\"225\" class=\"alignleft size-medium wp-image-1843\" srcset=\"https:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151839-300x225.jpg 300w, https:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/IMG_20130116_151839-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><video src='http:\/\/www.walking-productions.com\/notslop\/wp-content\/uploads\/2013\/01\/demo.mp4' controls \/><\/p>\n<p>There is a quick example of writing a file up on the JavaCV site which provides the foundation:  <a href=\"https:\/\/code.google.com\/p\/javacv\/source\/browse\/samples\/RecordActivity.java\">https:\/\/code.google.com\/p\/javacv\/source\/browse\/samples\/RecordActivity.java<\/a><\/p>\n<p>I have the beginnings of a full blown project (which needs some updating based on the above example) up on GitHub:  <a href=\"https:\/\/github.com\/vanevery\/JavaCV_0.3_stream_test\" title=\"JavaCV Stream Test\">https:\/\/github.com\/vanevery\/JavaCV_0.3_stream_test<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For the last little or should I say, long while I have been working on wrangling a solution for live streaming from Android that is both decent quality and extensible. For those of you interested, the litter in my GitHub account documents various previous attempts. As far as I can tell, most folks that are &hellip; <a href=\"https:\/\/www.walking-productions.com\/notslop\/2013\/01\/16\/android-live-streaming-courtesy-of-javacv-and-ffmpeg\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Android Live Streaming courtesy of JavaCV and FFMPEG<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[97,27,76,41,18,57,22,13,42],"tags":[],"class_list":["post-1838","post","type-post","status-publish","format-standard","hentry","category-android","category-development","category-flash","category-itp","category-java","category-mobile","category-open-source","category-streaming-and-multi-media","category-video"],"_links":{"self":[{"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/posts\/1838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/comments?post=1838"}],"version-history":[{"count":3,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/posts\/1838\/revisions"}],"predecessor-version":[{"id":1846,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/posts\/1838\/revisions\/1846"}],"wp:attachment":[{"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/media?parent=1838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/categories?post=1838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/tags?post=1838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}