Open slyvelikov opened 5 months ago
Hi @slyvelikov , It is not reproducing. I tried to reproduce using below snippet. i take the first frame of the video.
public static Bitmap getFrameAt(Activity context, Uri videoUri) {
try {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(context, videoUri);
Bitmap res= retriever.getFrameAtTime(0);
retriever.release();
return res;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
and i pass Uri.parse(TrimVideo.getTrimmedVideoPath(result.getData()));
to videoUri param.
try above snippet.
Hi @a914-gowtham and thank you for your quick response ! Im able to load videos with your library and trimming them, the issue comes after I stitch the 2 videos. So I have an app that allows the customers to "stitch" 2 videos. This is done when you record a video with a pause then Im making small chunks of videos out of these pauses. And after I trim one of the these chunks and then stitch it together with the other video parts and I cant get the thumbnail. Ive tried your snippet but it didnt work. Could this be because of a codec issues between your library and my stitching function ?
@slyvelikov are you using ffmpeg for stitching. if yes, you could check if both trimmer library and stitch functuon uses same version of ffmpeg.
Unfortunately, no, Im using file appending to "stick" them together.
could you share the sample code to append videos. @slyvelikov
public void appendFile(File fileToAppend) throws VideoFileException {
if (null == fileToAppend) throw new IllegalArgumentException();
if (null == mBaseFile) {
// If first pass, set fileToAppend as the base file
mBaseFile = fileToAppend;
return;
}
if (null != mOutputFile) {
// If nth pass, set previous output file as the base file
mBaseFile = mOutputFile.getFile();
}
if (!fileToAppend.getAbsolutePath().equals(mBaseFile.getAbsolutePath())) {
mOutputFile = new VideoFile();
// Log.d(TAG, "Invoking service to append " + fileToAppend.getName() + " to " + mBaseFile.getName()); // Log.d(TAG, "Service to write composite file fileToAppend: " + fileToAppend.getAbsolutePath()); // Log.d(TAG, "Service to write composite file mBaseFile: " + mBaseFile.getAbsolutePath()); // Log.d(TAG, "Service to write composite file to: " + mOutputFile.getFile().getAbsolutePath()); // // Log.d(TAG, "Service mCtx: " + String.valueOf(mCtx)); Intent i = new Intent(mCtx, VideoStitchingService.class); i.putExtra(VideoStitchingService.INTENT_EXTRA_BASE_FILE, mBaseFile); i.putExtra(VideoStitchingService.INTENT_EXTRA_FILE_TO_APPEND, fileToAppend); i.putExtra(VideoStitchingService.INTENT_EXTRA_OUTPUT_FILE, mOutputFile.getFile()); mCtx.startService(i); } }
I think the trimmed videos have been corrupted or MediaMetadataRetriever is perceiving them as corrupted.
I'm not sure if we can join two videos by file appending. but, merging two videos using ffmpeg will defenitely work.
Hi ya ! As you can see from the title Im trying to create a thumbnail using MediaMetadataRetriever and the method .setDataSource(), but Im getting this error in my logcat and no thumbnail visually - getFrameAtTime: videoFrame is a NULL pointer. If I dont trim the video everything works fine. Also Im stitching 2 videos and Im trimming either of them. But if the videos arent trimmed it can make a thumbnail.