Có thể tải hình thu nhỏ từ url video không? Tôi cần hình thu nhỏ của video trong chế độ xem danh sách.Nhận hình thu nhỏ của video từ url video
Trả lời
Điều rất quan trọng là phải xác định các thành phần của sự cố. Tôi thực sự muốn nói rằng bạn có hai vấn đề riêng biệt:
Tải xuống tệp từ URL.
Tạo hình thu nhỏ từ tệp video không hoàn chỉnh.
Hãy xem hai cách riêng biệt, bạn sẽ tìm thấy nhiều thông tin.
Có thể có được hình thu nhỏ của video bằng ThumbnailUtils.
FileOutputStream out;
File land=new File(Environment.getExternalStorageDirectory().getAbsoluteFile()
+"/portland.jpg");// image file use to create image u can give any path.
Bitmap bitmap=ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Video.Thumbnails.FULL_SCREEN_KIND);//filePath is your video file path.
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] byteArray = stream.toByteArray();
out=new FileOutputStream(land.getPath());
out.write(byteArray);
out.close();
Tôi không thể sử dụng dòng này, Nó hiển thị lỗi, File land = new File (Environment.getExternalStorageDirectory(). GetAbsoluteFile() + "/ portland.jpg "); – Anitha
Tôi nhận được hình ảnh từ URL video thì tôi làm gì? .. Hãy giúp tôi. –
Giải pháp duy nhất tốt nhất, vì không giống như MINI_KIND và MICRO_KIND, FULL_SCREEN_KIND chỉ được lưu trữ trên db và không thể truy cập bằng đường dẫn URI. – MPaulo
Hãy thử ThumbnailUtils, để có được bitmap video từ đường dẫn tập tin
ThumbnailUtils.createVideoThumbnail(filePath,MediaStore.Video.Thumbnails.MINI_KIND);
không phải khi bạn đang phát trực tuyến. –
Nếu bạn đang đặc biệt yêu cầu về youtube
video sau đó tự động 4 tạo ra hình ảnh bằng Youtube.
http://img.youtube.com/vi/video_url_here/0.jpg
http://img.youtube.com/vi/video_url_here/1.jpg
http://img.youtube.com/vi/video_url_here/2.jpg
http://img.youtube.com/vi/video_url_here/3.jpg
Chuẩn hình ảnh kích thước
chơi nền Thumbnail (480x360 pixel) http://i1.ytimg.com/vi/G0wGs3useV8/0.jpg
Bắt đầu Thumbnail (120x90 pixel) http://i1.ytimg.com/vi/G0wGs3useV8/1.jpg
Trung Thumbnail (120x90 pixel) http://i1.ytimg.com/vi/G0wGs3useV8/2.jpg
End Thumbnail (120x90 pixel) http://i1.ytimg.com/vi/G0wGs3useV8/3.jpg
chất lượng cao Thumbnail (480x360 pixel) http://i1.ytimg.com/vi/G0wGs3useV8/hqdefault.jpg
Medium Chất lượng Thumbnail (320x180 pixel) http://i1.ytimg.com/vi/G0wGs3useV8/mqdefault.jpg
Chất lượng bình thường Thumbnail (120x90 pixel) http://i1.ytimg.com/vi/G0wGs3useV8/default.jpg
Hình thu nhỏ độ phân giải chuẩn (640x480 pixel) http://i1.ytimg.com/vi/G0wGs3useV8/sddefault.jpg
Maximum Nghị quyết Thumbnail (1920x1080 pixels) http://i1.ytimg.com/vi/G0wGs3useV8/maxresdefault.jpg
Có thể để có được một hình ảnh thu nhỏ từ một file video hoặc url sử dụng FFMPEG.
FFMPEG phải được tạo bằng cách sử dụng NDK (hoặc bạn có thể tìm thấy một số tệp nhị phân FFMPEG do Android tạo).Dưới đây là một dự án GitHub để xây dựng FFMPEG:
https://github.com/guardianproject/android-ffmpeg
Sau đó bạn có thể bao gồm những chương trình FFMPEG với ứng dụng của bạn và thực hiện FFMPEG từ mã trong ứng dụng của bạn để tạo ra một hình ảnh từ video (địa phương hoặc URL) bằng cách sử dụng lệnh như:
ffmpeg -i videosite.com/video.flv -ss 00:00:15.000 -vframes 1 thumbnail_out.png
Một điều cần cân nhắc là tìm thời gian (tùy chọn -ss) bạn lấy hình thu nhỏ để trở thành một hình ảnh có ý nghĩa đại diện cho video.
Để có được thu nhỏ từ URL, tôi chỉ có một giải pháp cho đến bây giờ, Bạn phải sử dụng This library
Nó Hỗ trợ tập tin, http, https, mms, mmsh và RTMP giao thức
và
Hỗ trợ aac, acc +, avi, flac, mp2, mp3, mp4, ogg, 3gp và hơn thế nữa! định dạng (âm thanh và video):
Có thể tải hình thu nhỏ của video từ url video.
Nếu loại video của bạn là Vimeo theo các bước dưới đây:
1) Giả video Url của bạn là: http://player.vimeo.com/video/17314292
2) Nhận Id video từ Url: ví dụ.
WS 3) Gọi với id video và định dạng XML http://vimeo.com/api/v2/video/17314292.xml
Bạn sẽ nhận được "thumbnail_small", "thumbnail_medium", "thumbnail_large" ở định dạng xml cho ngón tay cái video từ id Video
Nếu loại video của bạn là YouTube làm theo các bước dưới đây:
1) video Url: http://www.youtube.com/embed/Nl2iMF0yKW8
2) Nhận mã video từ url: ví dụ: Nl2iMF0yKW8
3) Thay id video trong url này http://i3.ytimg.com/vi/Nl2iMF0yKW8/default.jpg
LƯU Ý: Chỉ cần thay thế id của bạn ở đây.
Nó được làm việc trong trường hợp của tôi
Uri videoUri = data.getData();
String selectedPathVideo="";
selectedPathVideo = ImageFilePath.getPath(getApplicationContext(), videoUri);
Log.i("Image File Path", ""+selectedPathVideo);
try {
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(selectedPathVideo, MediaStore.Video.Thumbnails.MICRO_KIND);
imgFarmerVideo.setImageBitmap(thumb);
} catch (Exception e) {
e.printStackTrace();
}
Dự án Hỗ trợ file
public class ImageFilePath {
/**
* Method for return file path of Gallery image
*
* @param context
* @param uri
* @return path of the selected image file from gallery
*/
public static String getPath(final Context context, final Uri uri)
{
//check here to KITKAT or new version
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
// ExternalStorageProvider
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
}
// DownloadsProvider
else if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return getDataColumn(context, contentUri, null, null);
}
// MediaProvider
else if (isMediaDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
final String selection = "_id=?";
final String[] selectionArgs = new String[] {
split[1]
};
return getDataColumn(context, contentUri, selection, selectionArgs);
}
}
// MediaStore (and general)
else if ("content".equalsIgnoreCase(uri.getScheme())) {
// Return the remote address
if (isGooglePhotosUri(uri))
return uri.getLastPathSegment();
return getDataColumn(context, uri, null, null);
}
// File
else if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
return null;
}
/**
* Get the value of the data column for this Uri. This is useful for
* MediaStore Uris, and other file-based ContentProviders.
*
* @param context The context.
* @param uri The Uri to query.
* @param selection (Optional) Filter used in the query.
* @param selectionArgs (Optional) Selection arguments used in the query.
* @return The value of the _data column, which is typically a file path.
*/
public static String getDataColumn(Context context, Uri uri, String selection,
String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {
column
};
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
null);
if (cursor != null && cursor.moveToFirst()) {
final int index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(index);
}
} finally {
if (cursor != null)
cursor.close();
}
return null;
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is ExternalStorageProvider.
*/
public static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is DownloadsProvider.
*/
public static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is MediaProvider.
*/
public static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is Google Photos.
*/
public static boolean isGooglePhotosUri(Uri uri) {
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
}
}
- 1. Hình thu nhỏ của video
- 2. cách tạo hình thu nhỏ từ url video
- 3. Video hình thu nhỏ C#
- 4. Bắt hình thu nhỏ video video riêng tư trên Vimeo
- 5. Nhận video chụp nhanh cho hình thu nhỏ
- 6. Làm thế nào để có được hình thu nhỏ video Facebook từ id video của nó?
- 7. Tạo hình thu nhỏ từ các tệp video bằng Python
- 8. Lấy hình thu nhỏ của tệp video trong C#
- 9. iOS: nhận thời lượng video và hình thu nhỏ mà không cần phát video
- 10. cách tải hình thu nhỏ video của video youtube trong danh sách android trong android
- 11. Tải lên video và tạo hình thu nhỏ từ video trong django
- 12. Tôi làm cách nào để tạo hình thu nhỏ của url video trong android?
- 13. Cách tạo hình thu nhỏ hoặc xem trước cho video?
- 14. FFmpegPHP lấy hình thu nhỏ từ URL bên ngoài
- 15. Cách tạo hình thu nhỏ video trên YouTube trong Android?
- 16. FFMpeg - Tạo hình thu nhỏ cho tập tin video
- 17. Cách tạo hình thu nhỏ video bằng Python và Gstreamer
- 18. Lấy khung hình đầu tiên của video - Độ phân giải hình thu nhỏ - iPhone
- 19. Làm cách nào để tạo hình thu nhỏ từ video mpg với C#?
- 20. Cách tải hình thu nhỏ của video và tệp pdf trong php
- 21. Tôi làm cách nào để truy xuất chi tiết video YouTube từ URL video bằng PHP?
- 22. Lấy ID video YouTube trong URL và nhập ID video đã chọn vào URL
- 23. cách lấy id video youtube từ url
- 24. Nhận quay video NSData từ ALAsset url iOS
- 25. Hiện video Youtube và hình thu nhỏ trong định dạng đúng 09:16
- 26. Làm cách nào để che phủ nút phát qua hình thu nhỏ video?
- 27. cần tạo hình thu nhỏ để tải lên video (mã đơn giản)
- 28. Tạo video từ khung hình?
- 29. Tạo video từ hình ảnh
- 30. Cách nhận thời lượng của video được tải lên?
xem câu trả lời của tôi ... – Lokesh
@ user3726986 là nó ContentProvider Url hoặc Url như youtube? – SMR