Android To YouTube Live Event Streaming

386 views
Skip to first unread message

Busy WWW

unread,
Dec 12, 2015, 9:05:34 PM12/12/15
to javacv
Hello...
I am trying to rtmp streaming to YouTube live event from android device camera.
So far, I could do sending streaming using ffmpegframerecorder; however, the streaming is not well recognized from YouTube server.
On the YouTube live event controller, the message shows Good Health (and lagging with NO DATA for the half of times during the receiving). and the preview is not possible at all.
There are no special error messages, except slow data, frame size, key frame warning messages like so; which could be updated after some testing.
But, I could not see the actual live preview at all... ha ha ha

From android, the video mp4 local saving is very good and fast with ffmepgframerecorder.

Here are the RTMP sending information:
I used Android Studio with gradle option, and used the downloaded bin zip for .SO files. (currently on Windows, so I could not compile myself now)

mStreamLink >> is my YouTube event streaming url 
(for example: rtmp://a.rtmp.youtube.com/live2/myeventstreamingid)

mRecorder = new FFmpegFrameRecorder(mStreamLink, mImageWidth, mImageHeight, 1);
mRecorder.setFormat("flv");
//mRecorder.setFormat("mp4"); 
//MP4 option>>>>>> Never works for the YouTube RTMP (saving local mp4 files are OK), 
//actually error when recorder.record(frame)
mRecorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
mRecorder.setVideoOption("preset", "ultrafast");
mRecorder.setSampleRate(mSampleAudioRateInHz);
mRecorder.setFrameRate(15); //(mFrameRate);
mRecorder.setGopSize(60); // GOP_LENGTH_IN_FRAMES: framerate(15) * 4 = 30

Anyone and/or any help will be very appreciated....
Thanks.

Samuel Audet

unread,
Dec 18, 2015, 8:58:46 AM12/18/15
to jav...@googlegroups.com
What is the resolution of the images you are trying to stream? If it's
anything larger than something like 640x480, you can't expect a mobile
device to be able to compress that in real time using FFmpeg...

Samuel

On 12/13/2015 11:04 AM, Busy WWW wrote:
> Hello...
> I am trying to rtmp streaming to YouTube live event from android device
> camera.
> So far, I could do sending streaming using ffmpegframerecorder; however,
> the streaming is not well recognized from YouTube server.
> On the YouTube live event controller, the message shows Good Health (and
> lagging with NO DATA for the half of times during the receiving). and the
> preview is not possible at all.
> There are no special error messages, except slow data, frame size, key
> frame warning messages like so; which could be updated after some testing.
> But, I could not see the actual live preview at all... ha ha ha
>
> From android, the video mp4 local saving is very good and fast with
> ffmepgframerecorder.
>
> Here are the RTMP sending information:
> I used Android Studio with gradle option, and used the downloaded bin zip
> for .SO files. (currently on Windows, so I could not compile myself now)
>
> mStreamLink >> is my YouTube event streaming url
>
> (for example: *rtmp://a.rtmp.youtube.com/live2/myeventstreamingid)*

Busy WWW

unread,
Dec 18, 2015, 6:14:08 PM12/18/15
to javacv

OK, with many trial and error, I got finally could send see the YouTube live streaming from my android devices. The problem was not from ffmpeg, but from my YouTube live streaming apu code; I forgot to send streaming status (live) update right after sending video streaming which will set my streaming I'd to ready for users. As my network speed isn't fast enough, I send video size to 320x240 with pretty low quality. And then, it started to show in preview for about 10 seconds, then the android streaming is getting slow down which is not good enough for live view; lagging and buffering on the preview... My next problem to solve, but could not get improved yet; not sure where to start to solve slow ffmpeg sending performance...
My another issue is that, the rtmp port is blocking time to time when I use mobile data streaming; I checked the host name and ip address of YouTube rtmp address, and find that it sometimes gets the ipv6 address by mobile DNS server which could not resolve the YouTube rtmp by ffmpeg; it's my own analysis but could be wrong. Any thoughts about it???? I am getting tired by unknown answers with this project; but I will try to get solved .... Trying trying..... Ha ha ha.

Samuel Audet

unread,
Dec 27, 2015, 9:46:41 PM12/27/15
to jav...@googlegroups.com
On 12/19/2015 08:14 AM, Busy WWW wrote:
> OK, with many trial and error, I got finally could send see the YouTube live streaming from my android devices. The problem was not from ffmpeg, but from my YouTube live streaming apu code; I forgot to send streaming status (live) update right after sending video streaming which will set my streaming I'd to ready for users. As my network speed isn't fast enough, I send video size to 320x240 with pretty low quality. And then, it started to show in preview for about 10 seconds, then the android streaming is getting slow down which is not good enough for live view; lagging and buffering on the preview... My next problem to solve, but could not get improved yet; not sure where to start to solve slow ffmpeg sending performance...
> My another issue is that, the rtmp port is blocking time to time when I use mobile data streaming; I checked the host name and ip address of YouTube rtmp address, and find that it sometimes gets the ipv6 address by mobile DNS server which could not resolve the YouTube rtmp by ffmpeg; it's my own analysis but could be wrong. Any thoughts about it???? I am getting tired by unknown answers with this project; but I will try to get solved .... Trying trying..... Ha ha ha.

Yes, it's all very challenging. If you come up with working solutions,
be sure to publish them, here for example:
https://github.com/bytedeco/sample-projects
It will be very valuable to many people!!

Let me know if encounter any issues you can't solve though. I'm happy to
help with what I can. Thank you and good luck :)

Samuel

Busy WWW

unread,
Dec 27, 2015, 11:59:29 PM12/27/15
to javacv
Thanks, Samuel.
I made app (beta version) and published at the Play Store.
App name is My Live Event, and link is 
Quick screenshots are available at my web site

Tested on my Nexus devices, and worked somewhat. Not sure if app would work well on the other brand android devices; hope it works ....
There are still unsolved issues which I'm going to find the solutions in the future if I could do find one.
* reliable YouTube rtmp server connection from mobile network; connection from WiFi is little bit better ...
* better sound synchronization with video
* change video size and quality selective options
* more live event properties options; toggle live video saving, ... and others 
* .... etc

And the app source code is being uploaded at the my Drive folder and available soon.
The source code download link is available at the my web site
Or, direct zip file link:
As I am not a good coder, the source code is very dirty and not cleaned without any comments on it.
In the source, there is a library called "livestreaming" is not used at all and safe to remove from dependency; I planned to use it before I found the JavaCV solution...

Samir KHan

unread,
May 9, 2017, 7:28:19 PM5/9/17
to javacv
Hello Busy WWW,
These days,  am working on the same project. I have been stuck in the ffmpeg part (builing and importing to the project). Would you please help me how to import .so libs into the android project? I am using yt-watch app as a reference. 
Let me know if
Thanks,

Busy WWW

unread,
May 9, 2017, 7:38:26 PM5/9/17
to jav...@googlegroups.com
Hi, there.
You have to get the so files from javacv project download link; there might have newer versions. And need to add jar files as well.
And or, see if you have correct Gradle options for it.
Check my app structure and so and jar files.
If you have issues, please go to javacv source project web site; it shows many samples and references too.


--

---
You received this message because you are subscribed to a topic in the Google Groups "javacv" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/javacv/1t0KGmjVfVw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to javacv+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yogeshwar Suvarnkar

unread,
May 20, 2019, 9:00:54 AM5/20/19
to javacv
Hello sir,
     I am using your code for youtube live streaming implementation in android app, but the source code you provided is not working on device. 
"java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.busywww.myliveevent-7JwYx4NNe9e9A1QBqagSSw==/base.apk"],nativeLibraryDirectories=[/data/app/com.busywww.myliveevent-7JwYx4NNe9e9A1QBqagSSw==/lib/arm, /system/lib, /system/vendor/lib]]] couldn't find "libjniavutil.so"
"
 though i have all .so files under jniLIbs folder, sitll it's not working, but i downloaded your app MyLIveEvent and that's working fine, but not mine. Can you please help me with it.
To unsubscribe from this group and all its topics, send an email to jav...@googlegroups.com.

Busy WWW

unread,
May 20, 2019, 8:01:01 PM5/20/19
to jav...@googlegroups.com
Hi, there.
The error looks like missing so file. Would you check all the necessary SO files are in the source file? You could get latest so files from javacv projects; where I copied firm my project.
Thanks and good day.

To unsubscribe from this group and all its topics, send an email to javacv+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/javacv/2ef1c82b-9f64-4d90-be83-fe63b8f40079%40googlegroups.com.

Samuel Audet

unread,
May 20, 2019, 11:34:50 PM5/20/19
to jav...@googlegroups.com
They're probably not in the right directory. Try to copy the JAR files
instead.

On 5/20/19 9:55 PM, Yogeshwar Suvarnkar wrote:
> though i have all .so files under*jniLIbs* folder, sitll it's not
Reply all
Reply to author
Forward
0 new messages