Experience sharing of video editing for the Android platform short Technology.
Tip One: Everyone crossing, here is the video editor, that is, cut/splice/detach/merge/Doodle/tag/overlay/filter and other edits to the video. Please note that this is not a function of streaming media network playback.
Hint Two: These words 90% for the popularization of knowledge, 10% for the promotion of our SDK, because sharing others, beneficial self, is the virtuous circle, just can let us continue to share, after all, only share, not good is difficult to continue. To feed the family, ^_^.
Tip Three: We are a professional team of Android video editors, the following words to share, a complete practical experience summary, every knowledge point you can be in our SDK or open source project validation.
Our Sdk:https://github.com/lansosdk/lansoeditor_common (charged, but wrote 30 detailed notes, suitable for beginners to learn, can be used to practiced hand)
Open Source Engineering: https://github.com/WritingMinds/ffmpeg-android (free, need to compile by yourself, Linux and NDK required)
Both projects can be tested, learned, and then decided in what way to best benefit your project.
text :
1, do the video editing on Android, must start from the editor ffmpeg?
Not at all. Demand is the most important, Android from 4.1 to provide the Mediacodec class, you want to do video extract pictures, with Mediacodec or mediaextractor can be; you do video clipping, with Mediacodec can also; you have to do video scaling, with mediacodec+ OpenGL is the best choice; not necessarily with FFMEPG.
2, then why do many use FFmpeg to complete?
Because FFmpeg encapsulates a lot of formats, is flexible, simple, and compatible, his command line can save you a lot of time, such as video cropping ffmpeg-ss 10-t 20-i input-acodec copy-vcodec copy OUTPUT; is done, you don't need to write a lot of code yourself.
3,ffmpeg can help me do most of the video editing functions?
No optimized ffmpeg in function can, but performance is not. Due to the limitations of CPU performance, some commands are slow to handle, such as the overlay command, colorchannelmixer command EQ command, libx264 encoding function, so you realize the function, but the processing of a 10 second video, it takes 2 minutes, such a function , it is estimated to be difficult to use in the app. Our SDK for this case, do a hard decoder and hard encoder, fully accelerate the implementation of FFmpeg, which is the core of our SDK.
4,ffmpeg How do I start?
If you are a beginner, it is recommended not to compile ffmpeg as soon as it comes up, because there are too many projects compiled on GitHub online, and your goal is to learn to use it in your project. Moreover, if you want to use ffmpeg to achieve some complex operations, even if you spend a week to compile, the results found that the function can be satisfied, but the processing is too slow, can not be used at all, it is meaningless. Recommended with the above recommended two links, first learned to say, even if the version of the charge, but ffmpeg command code is public, the operation is unchanged, there is only time and other restrictions, learning FFMEPG is no hindrance. It is recommended to learn first, after all, familiar with the use of flexible.
5,ffmpeg which functions are executed faster, and can be implemented in free projects?
Like normal audio and video cutting, separating, compositing, stitching, encapsulation, format conversion these are possible. Because there is no use of video data decoding and coding operations, execution quickly, such as the second shot in the music that function, he used the command is: Audio cutting, the video in the audio separation, and then the new audio in and video merge, use the volume adjustment, can also be used ffmpeg amixer to achieve , such as the second shot in the video interception, in fact, is to use ffmpeg interception command to achieve, such as you directly MEDIACODEC encoded H264 naked stream to save the file, you want to encapsulate into MP4 format, so that other players can also play, then use the FFmpeg Package command can be achieved, Do not need to package yourself. If you only use these in your project, the free version will be available and the SDK will not be charged at all.
6, ordinary ffmpeg which function is slow, not suitable for use?
In some situations where you need to manipulate video pixel pixels, such as stacking with overlay, colorchannelmixer or EQ as filters, scaling with scale, using video decoding-----and re-coding.
The approximate work flow for these features is:
The first step of decoding, if the use of hardware decoding, it will be much faster, if the use of soft decoding, even after Neon batch processing optimization, processing speed is not ideal;
The second step, if you use colorchannelmixer this command, his working principle is to put 255 pixel values in advance according to your settings all into a table, in the processing of a pixel, using the table method to get the processed value, although faster, But compared with OpenGL is still very slow, after all, this is a pixel of a pixel to do, and OpenGL is the use of vector parallel processing, the speed of the total can not be compared;
The third step: Video encoding, ffmpeg itself without H264 video encoder, need to use external, such as libx264,libopenh264 these, but also soft coding.
Each frame of your video needs to go through these three steps to decode, process, and encode. So down, if 20 seconds of video, 25 frames per second, then is 500 frames, if not hardware acceleration to do, the speed estimation is difficult to complete.
Our SDK for this situation, do hard decoding and hard coding, speed up the execution of FFmpeg, let it run faster, this is the core of our SDK.
7, there is no good way, and want to realize the function, but also want to use the free version of?
Yes. In the form of mediacodec+ OpenGL, ffmpeg some slow-processing operations, all with MEDIACODEC+OPENGL to achieve, such as filters, such as overlays, such as scaling, and most of our advanced version of the operation is also used OpenGL to do, We have done a lot of work to make you like to operate a ArrayList class, add a media, delete a media, easy to use.
8, if we do it ourselves, we need to know what knowledge:
First of all, you should take it from the strategic ^_^, after all, it is not let you to engage in scientific research, to engage in sophisticated, to win the Nobel Prize. This is a technology, a very mature technology, similar to learning the Android UI, learning Java programming the same technology, need to accumulate knowledge in this and take the time to do things. If you are a beginner, it takes a long time to learn, to grope for things, and then to master the process.
And you have to focus on it tactically ^_^, the knowledge points involved are:
8.1 Linux Basic operation, here is strongly not recommended under Windows with Cygwin to engage, the first difficult to pass, the second less.
8.2 Ndk and JNI,GCC knowledge, because what you're going to do is ultimately encapsulated into a Java class and method, let the UI engineer call, and need to know some Java programming, so you can debug faster.
8.3 Video knowledge. This is necessary, and needless to say, after all, do is video editing, such as video format, audio, pcm,h264 basic knowledge, video bitrate, resolution, frame rate, ffmpeg commonly used commands and so on.
8.4 After knowledge of video, it is highly recommended to fully master Mediacodec and video playback principle, because this can save you a lot of time to achieve a function.
Summary: Do not compile on the first, the use of knowledge is important, with the free version of the cost of manpower and time costs, with our SDK can accelerate the development of your project, and our SDK costs far less than your labor cost and time cost ^_^.
Experience sharing of video editing for the Android platform short Technology.