byxiaobai
本帖最后由 tdiant 于 2023-3-31 10:56 编辑

我想调用ffmpeg来获取视频的每一帧
  1. plugins {
  2.     id 'eclipse'
  3.     id 'maven-publish'
  4.     id 'net.minecraftforge.gradle' version '5.1.+'
  5. }

  6. version = '1.0'
  7. group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
  8. archivesBaseName = 'modid'

  9. // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
  10. java.toolchain.languageVersion = JavaLanguageVersion.of(17)

  11. println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
  12. minecraft {
  13.     // The mappings can be changed at any time and must be in the following format.
  14.     // Channel:   Version:
  15.     // official   MCVersion             Official field/method names from Mojang mapping files
  16.     // parchment  YYYY.MM.DD-MCVersion  Open community-sourced parameter names and javadocs layered on top of official
  17.     //
  18.     // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
  19.     // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
  20.     //
  21.     // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
  22.     // Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started
  23.     //
  24.     // Use non-default mappings at your own risk. They may not always work.
  25.     // Simply re-run your setup task after changing the mappings to update your workspace.
  26.     mappings channel: 'official', version: '1.19.2'

  27.     // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.

  28.     // Default run configurations.
  29.     // These can be tweaked, removed, or duplicated as needed.
  30.     runs {
  31.         client {
  32.             workingDirectory project.file('run')

  33.             // Recommended logging data for a userdev environment
  34.             // The markers can be added/remove as needed separated by commas.
  35.             // "SCAN": For mods scan.
  36.             // "REGISTRIES": For firing of registry events.
  37.             // "REGISTRYDUMP": For getting the contents of all registries.
  38.             property 'forge.logging.markers', 'REGISTRIES'

  39.             // Recommended logging level for the console
  40.             // You can set various levels here.
  41.             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  42.             property 'forge.logging.console.level', 'debug'

  43.             // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  44.             property 'forge.enabledGameTestNamespaces', 'examplemod'

  45.             mods {
  46.                 examplemod {
  47.                     source sourceSets.main
  48.                 }
  49.             }
  50.         }

  51.         server {
  52.             workingDirectory project.file('run')

  53.             property 'forge.logging.markers', 'REGISTRIES'

  54.             property 'forge.logging.console.level', 'debug'

  55.             property 'forge.enabledGameTestNamespaces', 'examplemod'

  56.             mods {
  57.                 examplemod {
  58.                     source sourceSets.main
  59.                 }
  60.             }
  61.         }

  62.         // This run config launches GameTestServer and runs all registered gametests, then exits.
  63.         // By default, the server will crash when no gametests are provided.
  64.         // The gametest system is also enabled by default for other run configs under the /test command.
  65.         gameTestServer {
  66.             workingDirectory project.file('run')

  67.             property 'forge.logging.markers', 'REGISTRIES'

  68.             property 'forge.logging.console.level', 'debug'

  69.             property 'forge.enabledGameTestNamespaces', 'examplemod'

  70.             mods {
  71.                 examplemod {
  72.                     source sourceSets.main
  73.                 }
  74.             }
  75.         }

  76.         data {
  77.             workingDirectory project.file('run')

  78.             property 'forge.logging.markers', 'REGISTRIES'

  79.             property 'forge.logging.console.level', 'debug'

  80.             // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
  81.             args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')

  82.             mods {
  83.                 examplemod {
  84.                     source sourceSets.main
  85.                 }
  86.             }
  87.         }
  88.     }
  89. }


  90. // Include resources generated by data generators.
  91. sourceSets.main.resources { srcDir 'src/generated/resources' }

  92. repositories {
  93.     // Put repositories for dependencies here
  94.     // ForgeGradle automatically adds the Forge maven and Maven Central for you

  95.     // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
  96.     // flatDir {
  97.     //     dir 'libs'
  98.     // }
  99. }

  100. dependencies {
  101.     // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
  102.     // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
  103.     // The userdev artifact is a special name and will get all sorts of transformations applied to it.
  104.     minecraft 'net.minecraftforge:forge:1.19.2-43.2.0'
  105.     //implementation 'org.bytedeco:javacv:1.5.7'
  106.     implementation(group: 'org.bytedeco', name: 'javacv', version: '1.5.7') {
  107.         jarJar.pin(it, "1.5.7")
  108.     }
  109.     //implementation 'org.bytedeco:ffmpeg-platform:5.0-1.5.7'
  110.     implementation(group: 'org.bytedeco', name: 'ffmpeg-platform', version: '5.0-1.5.7') {
  111.         jarJar.pin(it, "5.0-1.5.7")
  112.     }
  113.     // Real mod deobf dependency examples - these get remapped to your current mappings
  114.     // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
  115.     // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
  116.     // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency

  117.     // Examples using mod jars from ./libs
  118.     // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")

  119.     // For more info...
  120.     // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  121.     // http://www.gradle.org/docs/current/userguide/dependency_management.html
  122. }

  123. // Example for how to get properties into the manifest for reading at runtime.
  124. jar {
  125.     manifest {
  126.         attributes([
  127.                 "Specification-Title"     : "catvideo",
  128.                 "Specification-Vendor"    : "examplemodsareus",
  129.                 "Specification-Version"   : "1", // We are version 1 of ourselves
  130.                 "Implementation-Title"    : project.name,
  131.                 "Implementation-Version"  : project.jar.archiveVersion,
  132.                 "Implementation-Vendor"   : "examplemodsareus",
  133.                 "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  134.         ])
  135.     }
  136. }

  137. // Example configuration to allow publishing using the maven-publish plugin
  138. // This is the preferred method to reobfuscate your jar file
  139. jar.finalizedBy('reobfJar')
  140. // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
  141. // publish.dependsOn('reobfJar')

  142. publishing {
  143.     publications {
  144.         mavenJava(MavenPublication) {
  145.             artifact jar
  146.         }
  147.     }
  148.     repositories {
  149.         maven {
  150.             url "file://${project.projectDir}/mcmodsrepo"
  151.         }
  152.     }
  153. }

  154. tasks.withType(JavaCompile).configureEach {
  155.     options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
  156. }
复制代码



结冰的离季
gradle 一般是用 shadow 打包依赖 https://github.com/johnrengelman/shadow
不过ffmpeg这类c语言一般是通过 命令行来交互的,比如replaymod 就是这样 https://github.com/ReplayMod/ReplayMod