Android live video streaming to Facebook with text Overlay - android

I had developed Android application that broadcast live video from android application to facebook. It is working fine, now I want to draw text on live video or pass that text to Facebook and display below the live video.
I am getting text using websocket, Whenever text comes from websocket, immediately I want to post that text to Facebook Live video, one way to do this is using FFMpeg
-vf "drawtext=fontsize=40:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
I feel this will make the video slower.
In android application I am using this code, to get RTMP Url for broadcasting...
GraphRequest request = GraphRequest.newPostRequest(
loginResult.getAccessToken(),
"/"+Profile.getCurrentProfile().getId()+"/live_videos",
new JSONObject("{\"title\":\"Today's Live Video\",\"description\":\"TV app.\"}"),
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
Intent i = new Intent(MainActivity.this, StreamingActivity.class);
startActivity(i);
}
Is there any way to draw the text in the live stream video or pass the text to facebook and display it below the live video as text overlay.

Related

How to get individual frames from a VLC MediaPlayer livestream on Android WITHOUT displaying the stream?

I am currently working on a project that requires me to stream video from an IP camera to an Android device via WiFi using RTSP and then do some image processing. I want to do this without displaying the video stream if possible. Currently, I am trying to do this using VLC for Android. My code is structured as follows:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayList<String> options = new ArrayList<>();
// Various options added.
mLibVLC = new LibVLC(getApplicationContext(), options);
mMediaPlayer = new MediaPlayer(mLibVLC);
videoLayout = findViewById(R.id.videoLayout); // This view is marked as INVISIBLE.
}
#Override
protected void onStart() {
super.onStart();
mMediaPlayer.attachViews(videoLayout, null, false, false);
Media media = new Media(mLibVLC, Uri.parse("<RTSP LINK>"));
// Set VLC media presets.
mMediaPlayer.setMedia(media);
media.release();
mMediaPlayer.play(); // Play the stream!
// Set callback to get each frame from MediaPlayer?
}
When videoLayout is marked as "visible", this works perfectly. I am also able to get Bitmaps from the view by performing a screen capture. When I mark the video layout as "invisible", far as I can tell I am still receiving frames (at least according to VLC's debug output) but I'm not sure how I can access them. Is there a way for me to directly render the MediaPlayer stream to a Bitmap? Or is there some other method I could use to get each new frame without rendering the view? Thanks for your help!
I figured this out after a lot of trial and error. The solution that worked best for me was to use FFMPEGFrameGrabber from JavaCV. I'm now able to read frame by frame from an RTSP stream.

Play Youtube Video in Cardboard mode

I'm developing a cardboard app. In my app I want to play a 360 youtube video, I want it to go straight to VR mode so the user doesn't have to remove their headset.
I don't mind whether this video is embedded in my app or opens the youtube app, but I need it go directly into VR mode with no non-VR interaction.
I've looked into doing the following:
streaming the video onto a surfaceTexture and using this to render stereoscoptically: not Possible
Launching the youtube app in cardboard mode: Not Possible
Using the YoutubePlayerView/Fragment/standalonePlayer : None expose functions to enable cardboard mode.
Is this possible?
I ended up using DASH with exoplayer.
I grabbed the direct url like so:
String GET_VIDEO_INFO_URL = "http://www.youtube.com/get_video_info";
Bundle params = new Bundle();
params.putString("video_id", info.getId());
UrlUtils.HttpURLRequest request = new UrlUtils.HttpURLRequest(GET_VIDEO_INFO_URL, "GET", params);
String response = request.execute();
if(response != null) {
Bundle urlParams = UrlUtils.decodeUrl(response);
String manifest_url = urlParams.getString("dashmpd", null);
info.setPath(manifest_url);
}
Then I use exoplayer to render the dash stream to a texture as explained here.

How can i use a video from google drive as my splash screen

At the moment im using a still image for my splash. but im revamping it at the moment and have made a splash using after effects. i have got some code that plays video as the splash but the file would be stored in app. i want to make it so that the video is stored on my google drive at this link.
https://drive.google.com/file/d/0B7ydVvZW0PBnQ3IxcEdIYVJfWGs/view?usp=sharing
then played in the media player using the code below. it doesnt have to be google drive if you can think of another site ic ould use to make easier then thanks as well.
String uriPath =
"https://drive.google.com/file/d/0B7ydVvZW0PBnQ3IxcEdIYVJfWGs" ;
Uri uri = Uri.parse(uriPath);
imgAnim.setVideoURI(uri);
imgAnim.requestFocus();
imgAnim.start();
// imgAnim.setVideoPath("android.resource://com.myapplication/" + R.drawable.vidio);
int SPLASH_DISPLAY_LENGTH = 8000;
new Handler().postDelayed(new Runnable() {
#Override
public void run() { if (count <= 5) {
finish();
Intent Logina = new Intent(getBaseContext(), Homescreen.class);
startActivity(Logina);
finish();
}
}
}, SPLASH_DISPLAY_LENGTH);
}
It's not recommend to use splash; Google used to advocate against splash screens, and even called it an anti-pattern.
In cold start sometime splash is good But If you want to play Video on SplashScreen it's not good Idea; Because streaming video take time and make user frustrated. If you don't have problem with this issue lot's of thread out there exist to play video [example].

vimeo video play in Android native

I am developing vimeo video app in native android. But it is not supported in VideoView. May I know any samples or related query for Android. I want final output to be in .mp3/.mp4 format.
I have tried iframe in Android WebView, It works well in Android WebView but I am not able to get seek bar. And OnPause() not able to Pause the video.
Here I am able to get Pause and Play button Only
Example: player.vimeo.com/video/49462103
I want play this video in android native
<VideoView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/videoView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
Update link in :
Vimeo site Thread-1
Vimeo site Thread-2
I am getting above error
I made a native player for vimeo, base by WebView. Support public and private video.
Try it : https://github.com/ct7ct7ct7/Android-VimeoPlayer
<com.ct7ct7ct7.androidvimeoplayer.view.VimeoPlayerView
android:id="#+id/vimeoPlayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
VimeoPlayerView vimeoPlayer = findViewById(R.id.vimeoPlayer);
getLifecycle().addObserver(vimeoPlayer);
//public video
vimeoPlayer.initialize(59777392);
//If video is open. but limit playing at embedded.
vimeoPlayer.initialize({YourPrivateVideoId}, "SettingsEmbeddedUrl")
//If video is pirvate.
vimeoPlayer.initialize({YourPrivateVideoId},"VideoHashKey", "SettingsEmbeddedUrl")
Vimeo's embed codes should work inside an Android WebView.
Vimeo only offers .mp4 links to PRO users on those users own videos.
Another option is to use the official Deep Link library for the android application. This will let you open any vimeo video in the Android app.
You can use Exoplayer to play vimeo Videos. Exoplayer is more customizable. All you need is to extract the url link from the video config link. You may use retrofit to extract the video url.
BASE_URL = "https://player.vimeo.com/video/"
You will need to use a get method like below:
#GET("{id}/{config}")
Call<JsonObject>getVideoLink(#Path("id") String id, #Path("config") String config);
You will get the id from video link. Example: "https://vimeo.com/123456789/" Here the id is: 123456789 .
JsonObject jsonObject = response.body();
JsonObject req = jsonObject.getAsJsonObject("request");
JsonObject file = req.getAsJsonObject("files");
JsonArray arr = file.getAsJsonArray("progressive");
String url = arr.get(0).getAsJsonObject().get("url").getAsString();
// Build the media item.
MediaItem mediaItem = MediaItem.fromUri(url);
// Set the media item to be played.
player.setMediaItem(mediaItem);
// Prepare the player.
player.prepare();
// Start the playback.
player.play();
Don't forget to initiate Exoplayer first.

Android, Trying to embed YouTube video in webpage

I’m trying to display a page of embed YouTube videos. I got the code from YouTube website. The page gets displayed correctly when I load it up in the browser but on my embedded web page the YouTube videos do not show the first frame. Its just a black box with the YouTube logo on the bottom. If you click on it, it does play the video. I tread to enable java script, still did not work.
public class cVideos extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videos);
WebView mWeb=(WebView) findViewById(R.id.webvideo);
mWeb.getSettings().setJavaScriptEnabled(true);
mWeb.getSettings().setJavaScriptEnabled(true);
// mWeb.loadUrl("http://www.besttechsolutions.biz/projects/bigbiz/mobvideo.php");
mWeb.loadUrl("http://www.besttechsolutions.biz/projects/bigbiz/videored.php");
}
}
Try embedding &autoplay=1 in the src attribute of the iframe tag in the page source.
Even so, autoplay will not work on Android 2.1 devices, as they cannot support HTML5 video in the browser.

Categories

Resources