KotlinFFMpeg icon indicating copy to clipboard operation
KotlinFFMpeg copied to clipboard

Some informations

Open Angelk90 opened this issue 6 years ago • 12 comments

@umair13adil : Hi, it would be possible to use this module, on a video that is online (http), the video weighs 658 (mb)?

Angelk90 avatar Jul 03 '18 12:07 Angelk90

Hi, currently this module only supports video files stored on SD card of mobile device. It can certainly work on huge video files. For online videos, this module can not work. Alternatively you can first download your video and then process it using this module.

umair13adil avatar Jul 03 '18 12:07 umair13adil

@umair13adil : But think to download a video of (658mb) that lasts 2 hours and 30 minutes, I think it is very heavy, like what. I can not find a solution.

Being that I am developing a player based on exoplayer, I would like to implement PreviewSeekBar on it: https://github.com/rubensousa/PreviewSeekBar

which allows you to have a preview of the video.

What would you recommend?

Angelk90 avatar Jul 03 '18 13:07 Angelk90

If you wan to use FFMpeg to display preview like in YouTube, you can use thumbnails, using following command:

ffmpeg -ss 00:00:10 -i 'yourVideo.mov' -vframes:v 1 'thumbnail.jpg'

Give it a try.

umair13adil avatar Jul 03 '18 13:07 umair13adil

@umair13adil : Everything must run on an android app, without using anything else.

Angelk90 avatar Jul 03 '18 13:07 Angelk90

@umair13adil

will this work on online video urls?

ffmpeg -ss 00:00:10 -i 'yourVideo.mov' -vframes:v 1 'thumbnail.jpg'

kasim1011 avatar Aug 01 '18 06:08 kasim1011

I have't tried it myself. But yes it's possible. Check this answer on Stackoverflow:

You can give a URL if the video is directly accessible at that URL.

umair13adil avatar Aug 01 '18 10:08 umair13adil

Hi , many thanks to you for this great work. Is there any way you can share with us regarding where to refer for how to use ffmpeg commands in Android ? It is hard to find any tutorials regarding it. If you have referred any link/document please share with us. Thank you once again.

HemanthKumarGB avatar Aug 02 '18 09:08 HemanthKumarGB

Hi, there is no single source of link/document for ffmpeg. You can use any ffmpeg command in Android using this library:

WritingMinds/ffmpeg-android

All commands have to be in array[] instead of plain string.

You can find some useful commands here: Useful FFmpeg commands

umair13adil avatar Aug 02 '18 09:08 umair13adil

Thank you for such a quick reply. Can we use the VideoMerge that you have implemented for concat/append video formats apart from Mp4 ? and what should be the value of scale in {stringBuilder.append("[$i:v]setpts=PTS-STARTPTS,setsar=1,setdar=4/3,scale=640x480[v$i]; [$i:a]asetpts=PTS-STARTPTS[a$i];")} to keep the original scaling of the video ? and also setdar to be as same as video's aspect ? Sorry to ask such silly queries , we have been digging ffmpeg from past 2 weeks and we are new to the ffmpeg library. Is there any way to reduce merging time as well ?

HemanthKumarGB avatar Aug 02 '18 10:08 HemanthKumarGB

Yes, you can use it to merge videos of different format.

Scale value is optional. If all your videos have some resolution , then simply don't add this filter, otherwise add it to specify single resolution for all videos.

If you wan't to keep original aspect ratio, scaling then just remove these filters.

You can reduce merge time by adding crf, preset and other options in your command, but they will reduce output video quality.

Here are some commands that you can use:

-crf: Quality. Range is logarithmic 0 (lossless) to 51 (worst quality). Default is 23. Subjective sane range is ~18-28 or so. Use the highest value that still gives you an acceptable quality. If you are re-encoding impractically large inputs to upload to YouTube or similar then try a value of 17 or 18 since these video services will re-encode anyway.

-preset: Encoding speed. A slower preset provides better compression (quality per file size) but is slower. Use the slowest that you have patience for: ultrafast, superfast, veryfast, faster, fast, medium (the default), slow, slower, veryslow.

-movflags +faststart: Allows video to playback before it is completely downloaded in the case of progressive download viewing. Useful if you are hosting the video, otherwise superfluous if uploading to a video service like YouTube.

-vf scale=-2:720,format=yuv420p: A filtergraph using scale and format video filters. Scale to 720 pixels in height, and automatically choose width that will preserve aspect, and then make sure the pixel format is compatible with dumb players.

-b:a 128k: Audio bitrate. If your ffmpeg is outdated then you'll need to add -strict experimental to use -c:a aac.

umair13adil avatar Aug 02 '18 10:08 umair13adil

Great! thanks . So my final filter after removing scaling and aspect ratio would be : [$i:v]setpts=PTS-STARTPTS; [$i:a]asetpts=PTS-STARTPTS[a$i]; ? as all my videos will be of same resolution and aspect ratio.

HemanthKumarGB avatar Aug 02 '18 10:08 HemanthKumarGB

yes, that's right.

umair13adil avatar Aug 02 '18 10:08 umair13adil