Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -gpl extension to FFmpeg (#419) #950

Merged
merged 15 commits into from
Sep 24, 2020

Conversation

tmurakam
Copy link
Contributor

  • add '-nogpl' extension.
  • cppbuild.sh: Disable GPL modules.
  • setup-source.sh: patch postproc.java.

- add '-nogpl' extension.
- cppbuild.sh: Disable GPL modules.
- setup-source.sh: patch postproc.java.
ffmpeg/cppbuild.sh Outdated Show resolved Hide resolved
- Add -gpl extension and remove -nogpl extension.
- Add more options for default (non-GPL) profile.
@tmurakam
Copy link
Contributor Author

tmurakam commented Sep 21, 2020

I had updated following points:

  • Add '-gpl' extension and remove '-nogpl' (Default is non-GPL)
  • Add more options for default profile.
  • Fix presets/*.java and add -gpl extension.

@saudet
Copy link
Member

saudet commented Sep 21, 2020

We only need to have one "extension" line like this in avutil and it should work:
https://github.com/bytedeco/javacpp-presets/blob/master/opencv/src/main/java/org/bytedeco/opencv/presets/opencv_core.java#L72
Can you let me know what happens with that?

We can also do it like this for modules that are only available with extension like postproc:
https://github.com/bytedeco/javacpp-presets/blob/master/opencv/src/main/java/org/bytedeco/opencv/presets/opencv_cudaarithm.java
That way, it doesn't get processed without extension.

@tmurakam
Copy link
Contributor Author

tmurakam commented Sep 22, 2020

We only need to have one "extension" line like this in avutil and it should work:

I've tried it, but it does not work for default (without) extension build. (It works for -gpl extension).
When remove the "extension" line for default, the source code is not generated (src/gen folder is empty), and no shared library are included in the jar file.

We can also do it like this for modules that are only available with extension like postproc:

It does not work, the compilation fails:

[ERROR] /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/avfilter/AVFilterInOut.java:[18,1] package org.bytedeco.ffmpeg.postproc does not exist

Any ideas?

@saudet
Copy link
Member

saudet commented Sep 22, 2020

It works for OpenCV, it'll work with FFmpeg for sure. Show me what you tried exactly.

@tmurakam
Copy link
Contributor Author

tmurakam commented Sep 22, 2020

It works for OpenCV, it'll work with FFmpeg for sure. Show me what you tried exactly.

Here is my reproduce steps.

First clone my repo from https://github.com/javacpp-nogpl/javacpp-presets on CentOS 7 machine, then:

# checkout working branch. The branch has only have one extension for presets/*.java (except for postproc).
git checkout ffmpeg-nogpl-extension-work

# Build ffmpeg for default (without extension)
mvn -pl ffmpeg install

The generated ffmpeg/target/ffmpeg-linux-x86_64.jar does not contains *.so files.

It seems that the presets/*.java file is not processed in javacpp:parse goal.

[INFO] Targeting /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/avcodec.java                                                        
[INFO] Nothing targeted for /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/avcodec.java                                             
[INFO] Targeting /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/avdevice.java                                                       
[INFO] Nothing targeted for /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/avdevice.java                                            
[INFO] Targeting /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/avfilter.java                                                       
[INFO] Nothing targeted for /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/avfilter.java                                            
[INFO] Targeting /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/avformat.java                                                       
[INFO] Nothing targeted for /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/avformat.java                                            
[INFO] Targeting /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/avutil.java                                                         
[INFO] Nothing targeted for /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/avutil.java                                              
[WARNING] Could not load platform properties for class org.bytedeco.ffmpeg.presets.postproc                                                                            
[INFO] Targeting /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/swresample.java                                                     
[INFO] Nothing targeted for /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/swresample.java                                          
[INFO] Targeting /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/swscale.java                                                        
[INFO] Nothing targeted for /home/tmurakam/dev/javacpp-presets/ffmpeg/src/gen/java/org/bytedeco/ffmpeg/global/swscale.java

@saudet
Copy link
Member

saudet commented Sep 22, 2020

I don't see a @Platform(extension = "-gpl") line in avutil anywhere.

@tmurakam
Copy link
Contributor Author

I understood how to write extension line.
I had updated the presets/*.java except for postprocess.

But I don't understand how to fix the postprocess.java, because the postprocess.h does not exist when --disable-gpl mode...

@saudet
Copy link
Member

saudet commented Sep 22, 2020 via email

@tmurakam
Copy link
Contributor Author

tmurakam commented Sep 22, 2020

Check the CUDA module for OpenCV above. If there are includes given only for an extension, they'll get ignored without extension.

It seems it does not work for FFmpeg, because avfilter inherits postproc:

@Properties(
    inherit = {avformat.class, postproc.class, swresample.class, swscale.class},

Can we remove the inheritance?

@saudet
Copy link
Member

saudet commented Sep 22, 2020 via email

- avfilter: do not inherit postproc.
- postproc: merge default/gpl code.
@tmurakam
Copy link
Contributor Author

tmurakam commented Sep 22, 2020

Ok, I had fixed the postproc and avfilter.

@tmurakam tmurakam changed the title Add -nogpl extension to FFmpeg (#419) Add -gpl extension to FFmpeg (#419) Sep 22, 2020
@saudet
Copy link
Member

saudet commented Sep 22, 2020

We should only need @Platform(extension = "-gpl") in avutil because it gets inherited.

@tmurakam
Copy link
Contributor Author

I had removed unnecessary @Platform(extension = "-gpl") lines.

@tmurakam
Copy link
Contributor Author

I had push the commit which revert the avfilter.java to inherit postproc.

Copy link
Member

@saudet saudet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also update the pom.xml file in README.md and the samples subdirectory with something like this:

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.bytedeco.ffmpeg</groupId>
    <artifactId>readfewframe</artifactId>
    <version>1.5.5-SNAPSHOT</version>
    <properties>
        <exec.mainClass>ReadFewFrame</exec.mainClass>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>ffmpeg-platform</artifactId>
            <version>4.3.1-1.5.5-SNAPSHOT</version>
        </dependency>

        <!-- Optional GPL builds with (almost) everything enabled -->
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>ffmpeg-platform-gpl</artifactId>
            <version>4.3.1-1.5.5-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>.</sourceDirectory>
    </build>
</project>

ffmpeg/cppbuild.sh Show resolved Hide resolved
ffmpeg/platform/gpl/pom.xml Outdated Show resolved Hide resolved
ffmpeg/pom.xml Outdated Show resolved Hide resolved
@tmurakam
Copy link
Contributor Author

I had updated the README.
I think "ffmpeg-platform" and "ffmpeg-platform-gpl" are exclusive, so we can use only one of them.

        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>ffmpeg-platform</artifactId>
            <version>4.3.1-1.5.5-SNAPSHOT</version>
        </dependency>

        <!-- Optional GPL builds with (almost) everything enabled -->
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>ffmpeg-platform-gpl</artifactId>
            <version>4.3.1-1.5.5-SNAPSHOT</version>
        </dependency>

@saudet
Copy link
Member

saudet commented Sep 23, 2020

I had updated the README.
I think "ffmpeg-platform" and "ffmpeg-platform-gpl" are exclusive, so we can use only one of them.

No, they are not mutually exclusive. The extension can be given at runtime. Also update sample/pom.xml, thanks!

@tmurakam
Copy link
Contributor Author

No, they are not mutually exclusive. The extension can be given at runtime. Also update sample/pom.xml, thanks!

Ok, I understood. I fixed the README and samples/pom.xml.

ffmpeg/platform/gpl/pom.xml Outdated Show resolved Hide resolved
@saudet
Copy link
Member

saudet commented Sep 23, 2020

One last thing is that we'll need to add -gpl builds to .travis.yml and .appveyor.yml like this:

...
      - os: linux
        env: PROJ=ffmpeg OS=android-arm
        install: true
        script: ./ci/install-travis.sh
      - os: linux
        env: PROJ=ffmpeg OS=android-arm EXT=-gpl
        install: true
        script: ./ci/install-travis.sh
etc...

@tmurakam
Copy link
Contributor Author

I had updated the .travis.yml and .appveyor.yml.

.appveyor.yml Outdated Show resolved Hide resolved
@saudet saudet merged commit cc6e41b into bytedeco:master Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants