shahen94 / react-native-video-processing

Native Video editing/trimming/compressing :movie_camera: library for React-Native
https://shahen94.github.io/react-native-video-processing/
MIT License
1.25k stars 325 forks source link

Licensing #78

Closed mannol closed 7 years ago

mannol commented 7 years ago

AFAIK this library is using: https://github.com/kesha-antonov/ffmpeg-android-java which is licensed under GPLv3. There should be a notice in the README about the limitations of using this library.

shahen94 commented 7 years ago

Hi @mannol . Thanks you for taking a look such things. I'm not sure that i understand what's the problem, can you please change it and open PR

mannol commented 7 years ago

Before I do so, it's important to understand the limitations of using GPL in a project: "(TL;DR from wikipedia) ... if GPLed parts are used in a program (and the program is distributed), then all other source code of the program needs to be made available under the same license terms". Therefore, this module (react-native-video-processing) can only be used in opensource software, unless, the license exception is made by the original author of the software in question (this is the original project that is GPL'd: https://github.com/WritingMinds/ffmpeg-android-java).

In summary: either keep using ffmpeg-android-java and be opensource only module or switch back to mp4parser to support proprietary use.

shahen94 commented 7 years ago

I'll not switch back to mp4parser, since it don't have features which can give us ffmpeg.

So seems like we need change the licence, or i need to write my own ffmpeg-android 🤒 library from scratch with MIT licence. Thanks for letting me know about this issue.

I'll keep this thread open, and will close this when i'll decide what to do with this issue

kesha-antonov commented 7 years ago

Hey guys! @mannol @shahen94

Please clarify.

If we use ffmpeg in react-native-video-processing then Can we use react-native-video-processing in commercial (not open sourced projects)?

kesha-antonov commented 7 years ago

Or the problem is not in the ffmpeg? https://video.stackexchange.com/questions/14802/can-i-use-ffmpeg-in-a-commercial-product

Problem in ffmpeg-android-java. Correct? https://github.com/WritingMinds/ffmpeg-android-java/blob/master/LICENSE.GPLv3

shahen94 commented 7 years ago

Problem is in ffmpeg-android-java . We can use this library in private projects, as i understand.

kesha-antonov commented 7 years ago

How about Commercial and available to public (not open sourced)?

shahen94 commented 7 years ago

It should be fine, just this library(and forks) can't be developed in private repositories. But i'd like to see what will say @mannol

kesha-antonov commented 7 years ago

If I understand correctly.

1) If we use ffmpeg-android-java -> then react-native-video-processing must be re-licensed under GPLv3. 2) If we use react-native-video-processing (which will be with GPLv3 license) -> then that Commercial project must be licensed under GPLv3 too.

Correct? @mannol @shahen94

kesha-antonov commented 7 years ago

If that is correct I'm going to write code that allow react-native-video-processing to work without ffmpeg-android-java...

shahen94 commented 7 years ago

@kesha-antonov how you're going to do that ?

kesha-antonov commented 7 years ago

I'm not sure now. But I think it's necessarily. I propose to join our forces and make it

It's just a binary ffmpeg that needs to be executed. Seems like not so difficult task

kesha-antonov commented 7 years ago

I'll try to do some dummy implementation. And then we all will do something better

Now I'm trying to build ffmpeg with https://github.com/cisco/openh264 instead of x264. It's free. For x264 we have to pay for license. 🤕

I'll return once I'll make progress with this. Maybe in an other issue/PR


I see that we need:

  1. Build new ffmpeg binary. Without extra-libs, replace x264 -> openh264 (I'm doing this right now)
  2. Do dummy implementation of using ffmpeg binary to launch in our code base (Trimmer.java)

Anything else? For now it solvable 👍 Just will take a few days

mannol commented 7 years ago

@kesha-antonov yes, you are correct: ffmpeg-android-java is the problematic code. If you remove that, you can use ffmpeg in your code as long as you comply with the ffmpeg's guide for using ffmpeg in commercial applications. AFAIK ffmpeg-android-java is convenience wrapper over ffmpeg which simplifies instalation of ffmpeg for android applications. Creating something like it should be relatively trivial.

kesha-antonov commented 7 years ago

Alright.

Then we have no choice. We have to do those 2 tasks I mentioned above:

  1. Compile ffmpeg with openh264 (instead of libx264)
  2. Put those binaries in react-native-video-processing and do dummy implementation of calling ffmpeg.
kesha-antonov commented 7 years ago

2. Use dynamic linking (on windows, this means linking to dlls) for linking with FFmpeg libraries.

What this means to us? https://www.ffmpeg.org/legal.html

kesha-antonov commented 7 years ago

13. Remove any prohibition of reverse engineering from your EULA.

Is it OK for us?

Every solid EULA I know is against this. But FFmpeg wants us to remove that prohibition...

CaptAhak commented 7 years ago

Hi, since GPUImage is used on the iOS Side, could the following be a viable substitute for ffmpeg alltogether? https://github.com/CyberAgent/android-gpuimage

Just wanted to throw the idea out there.

kesha-antonov commented 7 years ago

@CaptAhak AFAIK GPUImage is not used on iOS side for crop, trim, compress video. It's just stubbed there for future work. (or maybe for filters?). I'm using only API.

Correct? @shahen94

shahen94 commented 7 years ago

@kesha-antonov that's correct, GPUImage is still not used on iOS side for crop, we'll use it for filters

shahen94 commented 7 years ago

@CaptAhak i'm not sure that GPUImage have the same features which have ffmpeg

kesha-antonov commented 7 years ago

The question is - What to use in android.

I was able to build ffmpeg with openh264. I will try to link it and use without ffmpeg-android-java

kesha-antonov commented 7 years ago

If there any other solution for android with Trim/Crop/Compress with Permissive License I will help to integrate it here.

mannol commented 7 years ago

@kesha-antonov I think ffmpeg is your best bet. About the questions you asked:

Use dynamic linking (on windows, this means linking to dlls) for linking with FFmpeg libraries

That means that you are forced to link dynamically if you were to link with FFmpeg in your binary. Considering that you will not link FFmpeg in your binary (or any binary using react-native-video-processing) in any way but, rather, use the FFmpeg stand-alone binary, you are covered concerning that rule.

Remove any prohibition of reverse engineering from your EULA

Same as above. You are not linking with FFmpeg henceforth, different rules apply. See this answer for more detailed info. Specifically these lines:

If the program uses fork and exec to invoke plug-ins, then the plug-ins are separate programs, so the license for the main program makes no requirements for them

non-GPL application calls a GPL application at the command line -> definitely legal

Hope these answers help.

kesha-antonov commented 7 years ago

@mannol Nice. I think it's good for us.

You meant LGPL application, right? Not GPL?


Now about binaries.

Correct me if I'm wrong:

we must have 2 binaries separately 1) App with react-native-video-processing 2) ffmpeg binaries

We put ffmpeg binaries in react-native-video-processing in the assets directory. And then call them from App with loadFfmpeg

Where loadFfmpeg is our new dummy method to load ffmpeg binaries (copy/execute...?)

Or what is the correct way to separate binaries to run ffmpeg correctly (with dynamic linking)?

I'm pretty new to android dev. I appreciate any help/suggestions

shahen94 commented 7 years ago

We can put binaries in libraries/ffmpeg director - Then we should call loadFFMPEG in RNVideoProcessingPackage.java file

mannol commented 7 years ago

LGPL is more permissive than GPL. Regardless, same rules apply. About the implementation: you will, most likely, have to use Runtime.exec() function from java standard library to execute FFmpeg process.

Note about linking: linking several libraries in a single entity creates a single program. Since you will be using FFmpeg as a program, there is no linking of FFmpeg with react-native-video-processing. Therefore, as long as you use it like that (calling Runtime.exec() on FFmpeg binary), you are set.

EDIT: you must not load ffmpeg.so directly using System.load(). That way different rules apply.

kesha-antonov commented 7 years ago

OK! Thanks guys ! 👍 I'll try do it and will get back with questions

mannol commented 7 years ago

@kesha-antonov check the edit

kesha-antonov commented 7 years ago

Thanks! @mannol

kesha-antonov commented 7 years ago

Hey guys.

I've built ffmpeg with openh264. When I try to compress video with libopenh264 it gives me error: CANNOT LINK EXECUTABLE. library "libopenh264.so" not found page record for 0x..... was not found (block_size=16)

Does this mean that i should put libopenh264.so in the same directory with ffmpeg? I did not found options to disable shared libs.

https://github.com/cisco/openh264 https://github.com/cisco/openh264/issues/1529

kesha-antonov commented 7 years ago

I saw that libx264 was compiled with these options and worked without errors.

--enable-static \
--disable-shared \

But I don't see these options for building openh264

Maybe I should put some other flags?

https://github.com/cisco/openh264/blob/master/Makefile

shahen94 commented 7 years ago

Seems like you should put libopenh264 in the project. https://trac.pjsip.org/repos/ticket/1758

mannol commented 7 years ago

Shared libraries should go in libs/ directory (probably android/app/src/libs/armeabi-v7a/ for react native). I think it should work even if you place it in the same directory as your binary.

kesha-antonov commented 7 years ago

Alright! I'll try both

kesha-antonov commented 7 years ago

Same error.

https://github.com/kesha-antonov/ffmpeg-android-java/commit/de38625d61804bb23e252636cbaa4e86b8267f9e

Any thoughts?

kesha-antonov commented 7 years ago

Tried to put in node_modules/react-native-video-processing/android/src/main/jniLibs/. Same error

mannol commented 7 years ago

Try to place them in modules/react-native-video-processing/android/src/main/jniLibs/armeabi-v7a/

kesha-antonov commented 7 years ago

Already. That did not help (same error)

ls node_modules/react-native-video-processing/android/src/main/jniLibs
armeabi-v7a/ x86/

Can you help me to integrate it into RN-video-processing ? I have ffmpeg with openh264 + libopenh264.so It's time for task №2 - somehow integrate it here without ffmpeg-android-java

kesha-antonov commented 7 years ago

Maybe it copies ffmpeg to some other directory where ffmpeg can't see *.so ? https://github.com/kesha-antonov/ffmpeg-android-java/blob/master/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegLoadLibraryAsyncTask.java#L27

kesha-antonov commented 7 years ago

Guys. Really need your help Working on this > 24 hours already

Here's results: 1) Scripts to build ffmpeg with openh264: https://github.com/kesha-antonov/ffmpeg-android/commits/release/v0.4 2) Builds: https://github.com/kesha-antonov/ffmpeg-android-java/commits/master (ffmpeg with openh264 + .so files) 3) RN-video-processing with openh264: https://github.com/kesha-antonov/react-native-video-processing/commits/get_rid_of_ffmpeg_android_java

I don't have time anymore for now Let's continue and finish it. We all need this ASAP

kesha-antonov commented 7 years ago

Here's what ffmpeg gives about license:

screen shot 2017-07-12 at 12 54 05
kesha-antonov commented 7 years ago

Crop and Trim are working. Compress (which requires openh264) does not.

So maybe better to do integration of ffmpeg and then fix that error with shared lib.

kesha-antonov commented 7 years ago

One more thing.

RN-video-processing uses https://github.com/wseemann/FFmpegMediaMetadataRetriever which uses ffmpeg https://github.com/wseemann/FFmpegMediaMetadataRetriever/tree/master/gradle/fmmr-library/library/src/main/ffmpeg

Right? Should we do some about it too?

shahen94 commented 7 years ago

I'm not sure, maybe @mannol can help you with that question.

@kesha-antonov i'm in vacation in these days, i'll try to help when i'll get to my computer

mannol commented 7 years ago

Looks like FFmpegMediaMetadataRetriever uses FFmpeg directly (links with FFmpeg), and I've checked their FFmpeg build flags which seem to comply with guidelines provided by FFmpeg project. It's ok to use it for this project.

kesha-antonov commented 7 years ago

Ok guys! Thanks!

kesha-antonov commented 7 years ago

Hello @shahen94 Have you had time to try to link ffmpeg and "libopenh264.so" shared lib?

shahen94 commented 7 years ago

Hi @kesha-antonov , sorry for slow reply. I'm in vacation and will get back in the end of August. I'll work on this right away when i'll back to home

kesha-antonov commented 7 years ago

@shahen94 Ok!

I think we need to add warning in the README. To people know about problem with licensing

I'll try to find time to solve this and make build