Comments (9)
你可以用https://github.com/itinance/react-native-fs 下载视频成为一个 file
然后用 RNThumbnail 取thumbnail
const url = '/path/to/remote/file'
const filePath = RNFS.DocumentDirectoryPath + '/video.mp4';
RNFS.downloadFile(url, filePath).promise.then(res => {
RNThumbnail.get(filePath).then((result) => {
console.log(result.path); // thumbnail path
})
});
from react-native-thumbnail.
会出现偶尔会出错的情况吗,我这边偶尔会失败,
from react-native-thumbnail.
let thumbnail = await RNThumbnail.get(video.path);
偶尔会失败取不到
from react-native-thumbnail.
@wulala1997 什么原因?有log吗?
try {
let thumbnail = await RNThumbnail.get(video.path);
} catch (e) {
console.error(e)
}
会有log
from react-native-thumbnail.
处理的视频==> file:///storage/emulated/0/Pictures/video-2d880eef-a48a-4087-8239-cd0f2f3704058393300293092977467.mp4
Error: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
Error: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
at createErrorFromErrorData (blob:http://localhost:8081/adc8e4f3-6ae3-4477-b98c-04a67572c11c:14608:17)
at blob:http://localhost:8081/adc8e4f3-6ae3-4477-b98c-04a67572c11c:14567:27
at MessageQueue.__invokeCallback (blob:http://localhost:8081/adc8e4f3-6ae3-4477-b98c-04a67572c11c:15429:18)
at blob:http://localhost:8081/adc8e4f3-6ae3-4477-b98c-04a67572c11c:15155:18
at MessageQueue.__guard (blob:http://localhost:8081/adc8e4f3-6ae3-4477-b98c-04a67572c11c:15343:13)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:8081/adc8e4f3-6ae3-4477-b98c-04a67572c11c:15154:14)
at http://localhost:8081/debugger-ui/debuggerWorker.js:80:58
from react-native-thumbnail.
from react-native-thumbnail.
可能是错误在这 image.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
因为
Bitmap image = retriever.getFrameAtTime(1000000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
所以视频不到1秒那就没有 retriever.getFrameAtTime(1000000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
你检查你的视频是否不到一秒。
from react-native-thumbnail.
好的,十分感谢.抱歉打扰您中午休息了
from react-native-thumbnail.
没问题,我在越南现在还是工作时间。
from react-native-thumbnail.
Related Issues (20)
- Feature Request: Support setting the timestamp for the created thumbnail
- Height and width of 0 thumbnail result HOT 1
- More than one library with package name 'com.reactlibrary' [Android] HOT 2
- How should the filepath be? HOT 4
- Request: Add provision to select thumb from given time
- Error building for android: more than one library with package name 'com.reactlibrary' HOT 1
- Gradle DSL method not found: 'google()' HOT 1
- Thumbnails are blurry HOT 2
- Android requires storage permission
- Cannot resolve symbol 'reactlibrary' HOT 6
- any way to assign the return file path to variable? HOT 1
- So it doesn't support IOS? HOT 5
- Android publishing application failed HOT 5
- Cache Handling HOT 1
- is there any option to decrease image size?
- Unhandled Promise Reject: No such file or directory HOT 5
- How to get the first tick of frame?
- not work in Android
- Does not work with latest react-native 0.60.x HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-thumbnail.