Anyone nterested on using FFMPEG inside own app?

DonManfred

Expert
Licensed User
Longtime User
Hello anyone,

i´m doing a wrapper for ffmpeg actually...

It seems to work but as i dont have worked with ffmep in the past i dont have some good commandline examples to convert a video to flv for example. Or to reduce the quality (videosize)...

So my question. Can someone provide some example commandlines to

- Convert a videofile to a much smaller one with lesser quality to reduce internet traffic when on the field...

As for now i´m trying the command
B4X:
ffmpg.executecommand(Array As String("-i",File.Combine(extsdcard,"DCIM/Camera/"&flist.Get(0))))

and it results in this output so far



So. If anyone could provide other example commandlines then i will try to use these commands with my videos to see it the library is working

Comments are highly welcome
 

DonManfred

Expert
Licensed User
Longtime User
The video source is 29,1mb mp4
The video destination is 1,1mb flv

Seems to work

B4X:
ffmpg.executecommand(Array As String("-i",File.Combine(extsdcard,"DCIM/Camera/"&flist.Get(0)),"-s","400x300","-b","512k","-async","50","-ar","11025","-ab","16k",File.Combine(File.DirRootExternal,"output_klein.flv")))

 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
To whom who are interested:

The library is using a small .so which is the man-in-the-middle between b4a and the ffmpeg executeable which is in the Assets and are called from within the library.

I dont know if it will work on older devices. I´m using my device (a Samsung S6 EDGE) for the tests. Android Version on device is Lollipop (5.1)
 

DonManfred

Expert
Licensed User
Longtime User
Another test

B4X:
        '-an -ss 0:0:2 -t 0:0:0.001 -i input.mp4 -f image2 -s 110x90 thumb%d.jpg
        ffmpg.executecommand(Array As String("-an","-ss","0:0:2","-t","0:0:0.001","-i",File.Combine(extsdcard,"DCIM/Camera/"&flist.Get(0)),"-f","image2","-s","110x90",File.Combine(File.DirRootExternal,"thumb%d.jpg")))

This should create a thumbnail image...



works
 

moster67

Expert
Licensed User
Longtime User
Very nice Don....now I don't need to do it Thank you.

It is good that you are using a small so-library. The so-library can be compiled according to which codecs, containers, protocol which you would like to support but the more you support, the bigger the so-files will become. See my FFmpeg_b4a wrapper I wrote some time ago for further information. Anyway, it would be nice when you have finished it if you could give a link later to the build and configuration process you used for compiling the so-library in case someone would like to enhance it or build one for different platforms (Arm, X86 etc).

I look forward to testing it.
 

DonManfred

Expert
Licensed User
Longtime User
It is good that you are using a small so-library.
No, i´m NOT doing a .so... The .so is available. The wrapper for b4a is 30kb jar and a few bytes of xml.
PLUS a 15mb ffmpeg executable inside the assets folder.

When i´m in the stage of beta testing i´ll send you a copy of it... For now it is nothing more than doing the wrappe and doing first steps in using it.
 

susu

Well-Known Member
Licensed User
Longtime User
I used ffmpeg to convert and stream video on my VPS, I think I can give you some commands. I'm using mobile so I will send you when I get my computer.
 

susu

Well-Known Member
Licensed User
Longtime User
Here some commands I used on CentOS, not sure it can be used in Android?

1. Save a stream into a file:
B4X:
ffmpeg -i http://www.example.com/playlist.m3u8 -vcodec copy -c:a aac -strict -2 -ar 44100 -ab 48k video.mp4

2. Save a stream into a file with subtitile:
B4X:
ffmpeg -i http://www.example.com/playlist.m3u8 -vcodec libx264 -c:a aac -strict -2 -ar 44100 -ab 48k -vf subtitles=subtitle.srt video.mp4

3. Add watermark into video:
B4X:
ffmpeg -i source.mp4 -vf "movie=/folder/logo.png [watermark]; [in][watermark] overlay=0:0 [out]" -vcodec libx264 -acodec copy -f mp4 video.mp4

4. Convert mp4 to webm format:
B4X:
ffmpeg -i source.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis video.webm

5. Convert mp4 to gif (from 00:00:02 and 5 seconds long):
B4X:
ffmpeg -t 5 -ss 00:00:02 -i video.mp4 clip.gif

6. Convert gif to mp4:
B4X:
ffmpeg -f gif -i clip.gif video.mp4
 

susu

Well-Known Member
Licensed User
Longtime User
@DonManfred , can your FFMPEG lib play streaming video? If yes, it will be the most powerful video player.
 

DonManfred

Expert
Licensed User
Longtime User
can your FFMPEG lib play streaming video?
No. you can see the lib as a kind of starter for the ffmpeg executable (cli).
Maybe it is possible to save a stream to a video. i did not tested susus sample commandlines.

I just tried the commandline to add an overlay to a video but it seems i cant get it to work.
Maybe the ffmpeg is doing something in backgroud.. but i dont get any progress as yet. Aehm... It started output but stopped at a line i did not expect the end of output. Maybe one or more of the parameter i did not send correctly
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…