18

enter image description here

I am looking for a library or open source project that provides UI for trimming videos as you see in the screenshot. Including

  • Range selector with ability to increase, decrease and move the selection
  • Thumbnails
  • Current position of playback

Just the UI not the trimming itself.

If there is no ready solution available, then I'd like to now how to combine existing UI elements in a smart manner to achieve this or something similiar.

Here is what I finally implemented: Range selector / range seekbar to trim video including thumbnails

OneWorld
  • 17,512
  • 21
  • 86
  • 136

8 Answers8

15

I couldn't find a specific library, but you could use the MediaMetadataRetriever to get the frames for the video specifying the exact time of the frame.

MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(videoFile.getAbsolutePath());
Bitmap bitmap = retriever.getFrameAtTime(timeInMiliSeconds * 1000,
                MediaMetadataRetriever.OPTION_CLOSEST_SYNC);

I hope this helps you.

Natan
  • 1,867
  • 13
  • 24
14

You can get the UI from TELEGRAM (messaging app) source code available at GitHub https://github.com/DrKLO/Telegram

Activity: VideoEditorActivity.java (https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java)

Layout: video_editor_layout.xml (https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/src/main/res/layout/video_editor_layout.xml)

They have implemented their custom UI components VideoSeekBarView and VideoTimelineView.

VideoSeekBarView (https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoSeekBarView.java)

VideoTimelineView (https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoTimelineView.java)

Attached is the Telegram VideoEditorActivity enter image description here

shanraisshan
  • 3,521
  • 2
  • 21
  • 44
  • 2
    Great screenshot! But GPL license ;( ;( ;( – OneWorld Apr 22 '16 at 07:58
  • 1
    this is the most promising solution. however, Due to the license I can't use it. If I'd try to get some ideas I'd probably and up copying the code;) I probably would reward the answer if the license would not be that strict. – OneWorld Apr 22 '16 at 14:14
  • @OneWorld did you find any solution for this ? It'd be great help I am searching for same :) – Nisarg Jun 16 '16 at 07:28
  • @Nisarg Hi! I initially thought about extracting the player code of the *Telegram project* into another app under GPL license and add some `Intent`s that other apps could broadcast to pass a video for trimming. However, meanwhile I created my own video trim activity using https://github.com/oli107/material-range-bar. I dropped the requirement of thumbnails. It was still a lot of work! So, you could raise yourself a monument and go the way I initially planned and share it on github. – OneWorld Jun 16 '16 at 07:43
  • @OneWorld Thanks for your reply, I have completed trimming functionality using seekbar, It woks fine. I just need UI like above or something similar to whats app or instagram if you have any suggestion/idea else If I'll find anything will update you :) – Nisarg Jun 16 '16 at 08:29
  • Not sure what classes you are refering to and if you comply to their license. – OneWorld Jun 16 '16 at 09:30
  • 1
    @SagarHudge Hope [this](https://github.com/iknow4/Android-Video-Trimmer) helps , just found – Nisarg Mar 02 '18 at 06:48
4

I think this library will fit your needs.

VideoTrimmer

Nikita Axyonov
  • 1,314
  • 8
  • 18
  • I installed the demo from https://android-arsenal.com/details/1/3714 and I think you are right. Great! The lib also includes the mp4 trimmer! But unfortunately too late for my project ;( – OneWorld Aug 26 '16 at 14:38
  • @NikitaAxyonov can you help me for this question https://stackoverflow.com/questions/48801158/rangeseekbarview-how-to-select-a-fixed-range-frame-using-custom-rangeseekbarview please. – Sagar Feb 15 '18 at 07:24
  • @Sagar , I am also stuck at showing the time frame of video being trimmed, have you found any solution with the Library mentioned in the answer ? – B.shruti Aug 05 '20 at 09:06
  • @B.shruti try this https://github.com/a914-gowtham/Android-video-trimmer library.it supports on android 10 as well – gowtham6672 Aug 14 '20 at 08:48
2

I searched a lot for something similar without success. At the end I decided to stop the development of this feature.

But today, I found this HERE. I don't know if it's ok.

desc

range selector

enter image description here

Current play position travels on the rangeselector after user clicked "play". However, you can't move play position.

Another possibility is to read the source code of the official Android's application. I know that you are searching a library, but this can be another solution, and if you'll understand the google sourcecode you'll able to achieve the same quality of the Gallery application by Google.

Look here (Trim*.java classes): https://android.googlesource.com/platform/packages/apps/Gallery2/+/android-6.0.1_r31/src/com/android/gallery3d/app/

Sorry man, probably there isn't any opensource library to do that. I hope that this two links could be useful for you.

OneWorld
  • 17,512
  • 21
  • 86
  • 136
Stefano Cappa
  • 575
  • 3
  • 17
2

Try the following example on Git to trime video like whatsapp .

this solution I have tried it's working perfectly this example includes the custom RangeSeekBarView , custom ProgressBarViewwith seekbar where you can select the video range of video you want trime and save to the destination

VideoTrimming Like Whatsapp

Sagar
  • 5,273
  • 4
  • 37
  • 50
  • I'm not working on that feature anymore. But it's probably worth looking at for other users! – OneWorld Feb 14 '18 at 10:17
  • @OneWorld I need help for this example ,I want to select maximum of `30s` from total duration but I am not able to figure out this please help if you have any idea any help will be accepted..plase – Sagar Feb 14 '18 at 14:07
  • @Sagar are you serious? )) Just ask a new question or ask the author of the lib. – OneWorld Feb 14 '18 at 16:19
  • need some update for saving video, then it should work – neo Nov 22 '21 at 01:42
1

FFMPEG is best option if you are facing problem to compile ffmpeg use this link https://github.com/WritingMinds/ffmpeg-android and follow commands from https://github.com/antpersan/CutVideoAndroid and for range Seekbar https://github.com/anothem/android-range-seek-bar or use shanrais suggested VideoSeekBarView

Krutik
  • 732
  • 6
  • 19
  • I don't look for trimming itselft. Just the UI. I already found a 2 thumbs rangebar for myself that works fine. – OneWorld Apr 22 '16 at 09:36
1

Media-for-mobile

Video processing Library

Functions

  • Transcode video
  • Join Video
  • Cut Video
  • Video Effect
  • Audio Effect
  • Get Media File Info
  • Time Scaling
  • List item

You can use its function by customizing your interface.

Sohail Zahid
  • 8,099
  • 2
  • 25
  • 41
0

thank you all for your help, i think to do that with c++ native code, i am not a professional on it, but still the best way to dealing with the UI especially when we have to create a professional timeline, for confirmation, the ffmpeg is one of the best libraries https://github.com/tanersener/mobile-ffmpeg to edit videos on android,