Is there any way to cut a video (mp4 or 3gp) on android, like use only the last 5 seconds of the movie... on iphone this is possible using the AVAssetExportSession but on android I haven't found anything similar, just maybe some references to ffmpeg library which seems complicated. Is there any easier way to do it?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
try this
its work on Gallery2 package installed devices
We can cut video using ffmpeg in Android.
For integrating FFmpeg in android we can use precompiled libraries like ffmpeg-android.
To cut a video we can use below command-
Here,
-ss
seeks to position
-y
Overwrite output files without asking.
-i
ffmpeg reads from an arbitrary number of input “files” specified by the -i option
-t
limit the duration of data read from the input file
-s
video output size
-r
Set frame rate
-vcodec
Set the video codec.
-b:v
Set the video bitrate
-b:a
Set the audio bitrate
-ac
Set the number of audio channels.
-ar
sets the sampling rate for audio streams if encoded
startMs
start time of video in milliseconds from where you want to cut
endMs
end time of video in milliseconds up to which you want to cut
I have created a sample android project on editing videos using FFMpeg which includes cutting video.Check it out-
https://github.com/bhuvnesh123/FFmpeg-Video-Editor-Android
and its tutorial at-
https://androidlearnersite.wordpress.com/2017/03/17/ffmpeg-video-editor/
You can try INDE Media for Mobile - https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials
It has transcoding\remuxing functionality as MediaComposer class and a possibility to select segments for resulted files. Since it uses MediaCodec API inside it is very battery friendly and works as fast as possible
You can do this with my mp4parser library. Have a look at the ShortenExample it does exactly what the name suggests. Since the library cannot re-encode the video it can only cut the video at I-frames. So the points in time where you can make a cut are quite coarse.
On Android 4.1 you can access the hardware codecs via MediaCodec API which could be an option (but I haven't seen any example of that yet)