titansgroup / k4l-video-trimmer Goto Github PK
View Code? Open in Web Editor NEWA library with UI and mechanisms to trim local videos on Android applications.
License: MIT License
A library with UI and mechanisms to trim local videos on Android applications.
License: MIT License
1.0.3
7.0.0
Motorola
G5 Plus
I implement one application in which I used this trimmer. When we apply custom duration of setMaxDuartion e.g 30 sec(30000 millisecond) Resulted video is not exatly 30 sec. It has random duration like 32,35 or 40 second.
It must be same that we give custom duration
Random duration near by given duration
1.0.3
8
Smasung
S8
unable to understand the issue as it working as independent sample/test app but when adding to my existing project generate error by clicking on save button.
java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.InputStream.close()' on a null object reference
at com.coremedia.iso.PropertyBoxParserImpl.(PropertyBoxParserImpl.java:67)
at com.coremedia.iso.IsoFile.(IsoFile.java:59)
at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:49)
at life.knowledge4.videotrimmer.utils.TrimVideoUtils.genVideoUsingMp4Parser(TrimVideoUtils.java:71)
at life.knowledge4.videotrimmer.utils.TrimVideoUtils.startTrim(TrimVideoUtils.java:65)
at life.knowledge4.videotrimmer.K4LVideoTrimmer$11.execute(K4LVideoTrimmer.java:293)
at life.knowledge4.videotrimmer.utils.BackgroundExecutor$Task.run(BackgroundExecutor.java:212)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
1.0.3
6.0.1
Motorola
G4 Plus
When I select a large file to trim, on clicking save app crashes with below log
FATAL EXCEPTION: pool-1-thread-1 Process: life.knowledge4.videocroppersample, PID: 32469 java.lang.OutOfMemoryError: Failed to allocate a 440786855 byte allocation with 11418026 free bytes and 239MB until OOM at java.nio.ByteBuffer.allocate(ByteBuffer.java:56) at com.googlecode.mp4parser.AbstractBox.parse(AbstractBox.java:110) at com.coremedia.iso.AbstractBoxParser.parseBox(AbstractBoxParser.java:107) at com.googlecode.mp4parser.BasicContainer.next(BasicContainer.java:185) at com.googlecode.mp4parser.BasicContainer.hasNext(BasicContainer.java:161) at com.googlecode.mp4parser.util.LazyList$1.hasNext(LazyList.java:55) at com.coremedia.iso.IsoFile.getMovieBox(IsoFile.java:102) at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:51) at life.knowledge4.videotrimmer.utils.TrimVideoUtils.genVideoUsingMp4Parser(TrimVideoUtils.java:71) at life.knowledge4.videotrimmer.utils.TrimVideoUtils.startTrim(TrimVideoUtils.java:65) at life.knowledge4.videotrimmer.K4LVideoTrimmer$12.execute(K4LVideoTrimmer.java:362) at life.knowledge4.videotrimmer.utils.BackgroundExecutor$Task.run(BackgroundExecutor.java:212) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)
When I click on Save or Channel button on Trim Section App is crash .
When I Click on Channel Button it give me following error :-
FATAL EXCEPTION: main
Process: com.ssalphax.videotrim, PID: 16292
java.lang.NullPointerException: Attempt to invoke interface method 'void life.knowledge4.videotrimmer.interfaces.OnTrimVideoListener.cancelAction()' on a null object reference
at life.knowledge4.videotrimmer.K4LVideoTrimmer$3.onClick(K4LVideoTrimmer.java:162)
at android.view.View.performClick(View.java:6267)
at android.view.View$PerformClick.run(View.java:24763)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6548)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
1.0.3
6.0.1
Motorola
G4 Plus
1.0.3
6.0.1
Motorola
G4 Plus
I atteched screenshot show the issue.
Like
When trim video then result video quality is low then original video
how to solve this problem
Please reply its urgent
I've noticed that when trimming the video of the repository, it crashes:
The exception says :
E: Unsupported mime 'audio/ac3'
E: FATAL EXCEPTION: pool-1-thread-1
Process: life.knowledge4.videocroppersample, PID: 26274
java.lang.IllegalStateException: Failed to add the track to the muxer
at android.media.MediaMuxer.nativeAddTrack(Native Method)
at android.media.MediaMuxer.addTrack(MediaMuxer.java:626)
How come?
When making it trim without sound, it works fine, but then I don't have sound in the output video (of course)...
I wrote about this issue here too:
https://stackoverflow.com/q/54573454/878126
I am getting an issue. I have downloaded the latest code and integrate it on Android Studio. When i select a video, k4l-video-trimmer successfully prepared the video and correctly shows video info and snapshots. I have set the max duration to 10 sec but when move the progressbar to crop the video at specific duration, the cropping duration which is showing on screen like (01:21 sec - 01:31 sec) for 10 sec will change to (01:21 sec - 01:36 sec) becomes 15 sec duration that is an issue and when I crop the video, it will crop it for 23 sec. I don't know how to resolve this issue. Please help me to resolve this issue
following error happend for my users, i can't reproduce this error, but crashlytics result is
Fatal Exception: java.lang.IllegalArgumentException Raw Text
--
| android.media.MediaMetadataRetriever.setDataSource (MediaMetadataRetriever.java:75)
| android.media.MediaMetadataRetriever.setDataSource (MediaMetadataRetriever.java:161)
| life.knowledge4.videotrimmer.view.TimeLineView$1.execute (TimeLineView.java:83)
| life.knowledge4.videotrimmer.utils.BackgroundExecutor$Task.run (BackgroundExecutor.java:210)
| java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:428)
| java.lang.Thread.run (Thread.java:761)
1.0.0
6.0.1
, 7.1.1
, 4.4.4
It's quite common to add a GIF to showcase the library features. That would be a nice to have.
hi i'm using this library and when i get the output file my ivdeo player can't recognize it as a video file. what is your encoding and how can i change it?
1.0.3
6.0.1
Motorola
G4 Plus
Hello i implemented your repo and it's great!, i love your work! i know you are working hard on it to fix all the bugs and i thank you for that!, i have a small problem after implementing and updating my application playstore i'm getting the following stack trace :
java.lang.NullPointerException:
at life.knowledge4.videotrimmer.K4LVideoTrimmer$4.onClick(K4LVideoTrimmer.java:173)
at android.view.View.performClick(View.java:5266)
at android.view.View$PerformClick.run(View.java:21548)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5777)
at java.lang.reflect.Method.invoke(Native Method:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
so i'm wondering what could be causing that, is it a problem with my implementation or is it a bug by your side ? if it's my side can you give me hints of what could be the problem ? thank you!
Hi,
inside FileUtils.java
there is a problem.
In getDataColumn
method you should manage the new ContentProvider management
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
column _data
table not exists.
If you want that this library works with Android >= N, please fix this issue.
We utilized some of the k4l components for our video assessment app Flipgrid. Many thanks go to the team behind k4l.
Typically will be called once the Video is properly loaded in the VideoTrimmer/VideoView etc..
Please add a constructor that takes in a single parameter, Context, so we don't have to mess with AttributeSet.
We can set the path where we want to save our trimmed video but it saves with the default name, How can I set the name of video manually?
hi
I am exactly looking for something like your app but in html5 javascript platform.
do you know any open source for that?
thanks
If video size more than 100 MB it not trim the video and it show this error and video is more than trim size like 120 sec. and size is 154MB it is not give error or not Trim the video.
java.lang.NullPointerException: Attempt to invoke interface method 'void life.knowledge4.videotrimmer.interfaces.OnTrimVideoListener.getResult(android.net.Uri)' on a null object reference
at life.knowledge4.videotrimmer.K4LVideoTrimmer$4.onClick(K4LVideoTrimmer.java:173)
at android.view.View.performClick(View.java:6267)
at android.view.View$PerformClick.run(View.java:24763)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6548)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
I expect the video to start playing from where the mHolderTopView
is set. Instead each time I push play, the video plays from the beginning.
1.1.3-SNAPSHOT
7.0.0
Samsung
Note 5
Play video on device
timeLine.setVideoURI(Uri.fromFile(File(path)))
It must be played as normal.
media player errors are exposed.
The exposed error log is as follows.
isPlaying: called in state MEDIA_PLAYER_STATE_ERROR
MediaPlayer: Error(100,2)
MediaPlayer: Error(1, -32)
MediaPlayer: Error(1, -32)
There is no error when playing the same video in VideoView.
What's the problem?
1.0.3
6.0.1
Samsung
J7
1.pick a video from gallery Note: selected video must be large movie of type .mkv OR .TS
2. Select some duration and trim
3. It will reproduce the error and app will be crashed
I am pasting the logs of the error here
//***************************************************************************************
09-14 13:38:24.406 27003-27378/com.app.hotspot4beauty E/UncaughtException: java.lang.OutOfMemoryError: Failed to allocate a 1195376660 byte allocation with 13769380 free bytes and 108MB until OOM
at java.nio.ByteBuffer.allocate(ByteBuffer.java:56)
at com.googlecode.mp4parser.AbstractBox.parse(AbstractBox.java:110)
at com.coremedia.iso.AbstractBoxParser.parseBox(AbstractBoxParser.java:107)
at com.googlecode.mp4parser.BasicContainer.next(BasicContainer.java:185)
at com.googlecode.mp4parser.BasicContainer.hasNext(BasicContainer.java:161)
at com.googlecode.mp4parser.util.LazyList$1.hasNext(LazyList.java:55)
at com.coremedia.iso.IsoFile.getMovieBox(IsoFile.java:102)
at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:51)
at life.knowledge4.videotrimmer.utils.TrimVideoUtils.genVideoUsingMp4Parser(TrimVideoUtils.java:71)
at life.knowledge4.videotrimmer.utils.TrimVideoUtils.startTrim(TrimVideoUtils.java:65)
at life.knowledge4.videotrimmer.K4LVideoTrimmer$11.execute(K4LVideoTrimmer.java:293)
at life.knowledge4.videotrimmer.utils.BackgroundExecutor$Task.run(BackgroundExecutor.java:212)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
//**********************************************************************************************************
1.0.3
6.0.1
Motorola
G4 Plus
1.0
and 1.1.3-SNAPSHOT
5.1.1
Samsung
SM-J500FN
The trimmed video
A 1kb mp4 without the video
At least return an error instead of the result ok
Hi, I have an issue, mHolderTopView position is before than startPosition and while video is playing its position will change and at the end of video its position is wrong and it is after the progressBarView and rangeSeekBarView.
also the position of progressBarView is sync with rangeSeekBarView at the start point, but while we will close to the end of video its position is a little before rangeSeekBarView.
I tested it on sony Xperia sp and android 4.3.
when click on save, application crashed and shows
java.io.FileNotFoundException: /external/video/media/33131: open failed: ENOENT (No such file or directory)
if file is not here then how its appearing in timeline view please look in this matter
1.0.3
6.0.1
Motorola
Turbo
it should save video in destination path
application crashed,
showing exception
java.io.FileNotFoundException: /external/video/media/33131: open failed: ENOENT (No such file or
directory)
Is there any way to customize the Video Range Slider? I need to change the range selector position as vertical. Please help.
I've noticed that some libraries that offer the same thing have a different license, which is less permissive.
Is it true that it's MIT license? No catch?
What does it use behind the scenes ? Any technical restrictions?
setMaxDuration() to video duration by default
i cant make a relase build is there any proguard for this library
You have done a very good job to write this code but now there is a problem that i have to fetch videos from external usb and trim them. but Android Native MediaPlayer API is not playing them. so kindly help me.
Regards
cant find OnK4LVideoListener when implementing it... :S
In the video playback the video is always played from the start (no matter the position of the range selector).
Also, the final trimmed video is of incorrect length.
For example, if I select the time range from 8 seconds to 18 seconds. It is always trimmed to the length 0 seconds to 18 seconds.
Is the left range selector position not used?
I think cancelClicked should do a bit of cleanup
Also it would be helpful if VideoView is exposed so that we can control some other aspects like its visibility etc..
In my use case the Trimmer is housed in a RelativeLayout and stays hidden. When required we make the RelLayout visible and set URI. But if we click cancel, there is no way to stop the video and hide the videoView. Hiding the Relativelayout does not help because our background is a GLSurfaceView and the Zorder thing messes things up.
Currently I have edited the Trimmer to make VideoView visible on setURI and stop playback & invisible on CancelClicked
FATAL EXCEPTION: pool-8-thread-1
Process: com.peoplescience, PID: 10208
java.lang.OutOfMemoryError
at java.nio.ByteBuffer.allocate(ByteBuffer.java:56)
at life.knowledge4.videotrimmer.utils.FileDataSourceViaHeapImpl.map(FileDataSourceViaHeapImpl.java:70)
at com.googlecode.mp4parser.BasicContainer.getByteBuffer(BasicContainer.java:223)
at com.googlecode.mp4parser.authoring.samples.DefaultMp4SampleList.get(DefaultMp4SampleList.java:181)
at com.googlecode.mp4parser.authoring.samples.DefaultMp4SampleList.get(DefaultMp4SampleList.java:1)
at com.coremedia.iso.boxes.mdat.SampleList.get(SampleList.java:41)
at com.coremedia.iso.boxes.mdat.SampleList.get(SampleList.java:1)
at java.util.AbstractList$SimpleListIterator.next(AbstractList.java:55)
at java.util.AbstractList$SubAbstractList$SubAbstractListIterator.next(AbstractList.java:201)
at java.util.AbstractCollection.toArrayList(AbstractCollection.java:349)
at java.util.AbstractCollection.toArray(AbstractCollection.java:339)
at java.util.ArrayList.addAll(ArrayList.java:188)
at com.googlecode.mp4parser.authoring.tracks.AppendTrack.getSamples(AppendTrack.java:372)
at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.build(DefaultMp4Builder.java:96)
at life.knowledge4.videotrimmer.utils.TrimVideoUtils.genVideoUsingMp4Parser(TrimVideoUtils.java:131)
at life.knowledge4.videotrimmer.utils.TrimVideoUtils.startTrim(TrimVideoUtils.java:64)
at life.knowledge4.videotrimmer.K4LVideoTrimmer$11.execute(K4LVideoTrimmer.java:293)
at life.knowledge4.videotrimmer.utils.BackgroundExecutor$Task.run(BackgroundExecutor.java:212)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
I have an issue that is not quite your issue, but I really need your help.
I've downloaded you code and changed the VideoView into a TextureView based one from here
now, the progress indicator is not working correctly (it's like its reading the wrong duration, but I checked, and it gets the right duration).
I cant understand where this bug is coming from.
6.0.1
Huawei
Nexus 6P
Please help me solve this issue.
thank you!
I want to get trimmed portion without button clickListner.how to get it.
Hey, I saw "onTrimStarted" and "onError" in OnTrimVideoListener in your example.
But in my project "compile 'life.knowledge4:k4l-video-trimmer:1.0'", I only found "getResult" and "cancelAction".
Thank you!
1.0.3
6.0.1
, 5.1
Meizu
, Xiaomi
MX5
, MI 5
Fatal Exception: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java)
at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java)
at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java)
at life.knowledge4.videotrimmer.view.TimeLineView$1.execute(TimeLineView.java:87)
at life.knowledge4.videotrimmer.utils.BackgroundExecutor$Task.run(BackgroundExecutor.java:212)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
1.0.3
6.0.1
Motorola
G4 Plus
Hello,
I wonder how it is possible to detect if user click directly on the Save button on the bottom right of the screen after he imported his video without changing any setting neither doing any trim (in other words : he kept the video full-length).
Thanks in advance !
IF i trimmed video for 1 second or 2 second still its trimmed video for 9 seconds
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.