How to create thumbnail of video url form server
Try this Create new AsyncTask
like this
public class DownloadImage extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImage(ImageView bmImage) {
this.bmImage = (ImageView ) bmImage;
}
protected Bitmap doInBackground(String... urls) {
Bitmap myBitmap = null;
MediaMetadataRetriever mMRetriever = null;
try {
mMRetriever = new MediaMetadataRetriever();
if (Build.VERSION.SDK_INT >= 14)
mMRetriever.setDataSource(urls[0], new HashMap<String, String>());
else
mMRetriever.setDataSource(urls[0]);
myBitmap = mMRetriever.getFrameAtTime();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (mMRetriever != null) {
mMRetriever.release();
}
}
return myBitmap;
}
protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
}
}
Than call this AsyncTask
like this
new DownloadImage(YourImageView).execute("Your URL");
EDIT
Or you can also use Glide
to create thumbnail of video from url
RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.drawable.placeholder_card_view);
requestOptions.error(R.drawable.placeholder_card_view);
Glide.with(getContext())
.load(path)
.apply(requestOptions)
.thumbnail(Glide.with(getContext()).load(path))
.into(ivVideoThumbnail);
Is it possible to Generate a thumbnail from a video url in android
It is not possible to create thumbnail from steaming link, you have to show it from server. Better upload a thumbnail along the video.
Use the below code to generate thumbnail
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail("picturePath", MediaStore.Video.Thumbnails.MINI_KIND);
Create thumbnail from selected video and store it in server
You can create VideoThumbnail from sdcard path like this.
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MINI_KIND);
Using ThumbnailUtils, you can create thumbnail of two types.
MediaStore.Images.Thumbnails.MICRO_KIND type will generate thumbnail of size 96 x 96.
MediaStore.Images.Thumbnails.MINI_KIND type will generate thumbnail of size 512 x 384.
After creating the thumbnail you can upload the bitmap created directly to server giving the bitmap's reference that has been genereated.
create thumbnail from video URL in C#
Using NReco to Create Video Thumbnail:
I found my problem:
1: I have not used Server.MapPath. I had just entered relativePath.
2: it is not necessary the Video file be local it can be hosted someWhere else.
NReco just download the desired portion of video then extract the Thumbnail.
your Video file should be in localHost directory of your local server. I mean if your site is under development and video file is in your local Computer folder it WON'T Work because NReco requires byte range support in HTTP response Header file.
Unacceptable Link: "http://localhost:81882/content/AVSEQ01.mp4"
so for my local test, I have moved my video file to Local IIS directory : C:\inetpub\wwwroot\AVSEQ01.mp4
//sample remote video file
//string videoUrl = "http://phytonord.com/Film-Series/peik%20sahar/1.mp4";
//local video file
string localVideoFile = "http://localhost/AVSEQ01.mp4"
var ffMpeg = new NReco.VideoConverter.FFMpegConverter();
string thumbnailJPEGpath = Server.MapPath("~/Content/videoThumb.jpg");
ffMpeg.GetVideoThumbnail(videoUrl, thumbnailJPEGpath);
Related Topics
Is There on Install Event in Android
Simple Date Format Returns Wrong Date Intermittently
App Crashing When Trying to Use Recyclerview on Android 5.0
Android Httpclient Persistent Cookies
How to Fix Install_Parse_Failed_Manifest_Malformed in My Android Application
Read/Write .Txt File with Special Characters
How to Get Ruby Generated Hmac for Sha256 That Is Url Safe to Match Java
Is a Hashmap Thread-Safe for Different Keys
How to Find How Much Disk Space Is Left Using Java
Android: How to Use Download Manager Class
How to Resolve "Duplicate Files Copied in APK Meta-Inf/*"
How to Change Method Behaviour Through Reflection
Fatal Exception: Firebase-Messaging-Intent-Handle -- Java.Lang.Noclassdeffounderror