mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 22:16:01 +00:00
Stuff
This commit is contained in:
1 parent
9c4a30d224
commit
666398e480
174 files changed
+8694
-2942
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package com.moulberry.flashback.combo_options;
|
||||
|
||||
public enum AspectRatio implements ComboOption {
|
||||
|
||||
ASPECT_16_9("16:9 (HDTV)", 16/9f),
|
||||
ASPECT_9_16("9:16 (Shorts)", 9/16f),
|
||||
ASPECT_240_1("2.40:1 (Widescreen)", 2.4f),
|
||||
ASPECT_1_1("1:1 (Square)", 1f),
|
||||
ASPECT_4_3("4:3 (Fullscreen)", 4/3f),
|
||||
ASPECT_3_2("3:2 (Photo)", 3/2f);
|
||||
|
||||
private final String text;
|
||||
private final float aspectRatio;
|
||||
|
||||
AspectRatio(String text, float aspectRatio) {
|
||||
this.text = text;
|
||||
this.aspectRatio = aspectRatio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String text() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public float aspectRatio() {
|
||||
return aspectRatio;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.moulberry.flashback.combo_options;
|
||||
|
||||
public interface ComboOption {
|
||||
|
||||
String text();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.moulberry.flashback.combo_options;
|
||||
|
||||
public enum Sizing implements ComboOption {
|
||||
|
||||
KEEP_ASPECT_RATIO("Keep Aspect Ratio"),
|
||||
FILL("Fill"),
|
||||
UNDERLAY("Underlay"),
|
||||
CHANGE_ASPECT_RATIO("Change Aspect Ratio");
|
||||
|
||||
private final String text;
|
||||
|
||||
Sizing(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String text() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.moulberry.flashback.combo_options;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import org.bytedeco.ffmpeg.avcodec.AVCodec;
|
||||
import org.bytedeco.ffmpeg.avcodec.AVCodecHWConfig;
|
||||
import org.bytedeco.ffmpeg.global.avcodec;
|
||||
import org.bytedeco.ffmpeg.global.avutil;
|
||||
import org.bytedeco.javacpp.BytePointer;
|
||||
import org.bytedeco.javacpp.IntPointer;
|
||||
import org.bytedeco.javacpp.Pointer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public enum VideoCodec implements ComboOption {
|
||||
|
||||
H264("H264 (AVC)", avcodec.AV_CODEC_ID_H264),
|
||||
H265("H265 (HEVC)", avcodec.AV_CODEC_ID_H265),
|
||||
AV1("AV1", avcodec.AV_CODEC_ID_AV1),
|
||||
VP9("VP9", avcodec.AV_CODEC_ID_VP9),
|
||||
PRO_RES("Apple ProRes", avcodec.AV_CODEC_ID_PRORES),
|
||||
QUICK_TIME("QuickTime", avcodec.AV_CODEC_ID_QTRLE);
|
||||
|
||||
private final String text;
|
||||
private final int codecId;
|
||||
private String[] encoders;
|
||||
|
||||
VideoCodec(String text, int codecId) {
|
||||
this.text = text;
|
||||
this.codecId = codecId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String text() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public int codecId() {
|
||||
return this.codecId;
|
||||
}
|
||||
|
||||
public String[] getEncoders() {
|
||||
if (this.encoders == null) {
|
||||
List<String> encodersHardware = new ArrayList<>();
|
||||
List<String> encodersHybrid = new ArrayList<>();
|
||||
List<String> encodersSoftware = new ArrayList<>();
|
||||
List<String> encodersAvoid = new ArrayList<>();
|
||||
|
||||
try (Pointer pointer = new Pointer()) {
|
||||
while (true) {
|
||||
try (AVCodec codec = avcodec.av_codec_iterate(pointer)) {
|
||||
if (codec == null) {
|
||||
break;
|
||||
} else if (codec.id() == this.codecId && avcodec.av_codec_is_encoder(codec) != 0) {
|
||||
int capabilities = codec.capabilities();
|
||||
String name = codec.name().getString();
|
||||
|
||||
if ((capabilities & avcodec.AV_CODEC_CAP_HARDWARE) != 0) {
|
||||
encodersHardware.add(name);
|
||||
} else if ((capabilities & avcodec.AV_CODEC_CAP_HYBRID) != 0 || codecHasHwConfig(codec)) {
|
||||
encodersHybrid.add(name);
|
||||
} else if ((capabilities & avcodec.AV_CODEC_CAP_EXPERIMENTAL) != 0 || name.equals("libaom-av1")) {
|
||||
encodersAvoid.add(name);
|
||||
} else {
|
||||
encodersSoftware.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> encoders = new ArrayList<>();
|
||||
encoders.addAll(encodersHardware);
|
||||
encoders.addAll(encodersHybrid);
|
||||
encoders.addAll(encodersSoftware);
|
||||
encoders.addAll(encodersAvoid);
|
||||
|
||||
this.encoders = encoders.toArray(new String[0]);
|
||||
}
|
||||
|
||||
return this.encoders;
|
||||
}
|
||||
|
||||
private static boolean codecHasHwConfig(AVCodec codec) {
|
||||
try (AVCodecHWConfig config = avcodec.avcodec_get_hw_config(codec, 0)) {
|
||||
return config != null;
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.moulberry.flashback.combo_options;
|
||||
|
||||
import org.bytedeco.ffmpeg.avformat.AVOutputFormat;
|
||||
import org.bytedeco.ffmpeg.global.avcodec;
|
||||
import org.bytedeco.ffmpeg.global.avformat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum VideoContainer implements ComboOption {
|
||||
|
||||
MP4("MP4", "mp4"),
|
||||
MKV("MKV", "mkv"),
|
||||
AVI("AVI", "avi"),
|
||||
MOV("MOV", "mov");
|
||||
|
||||
private final String text;
|
||||
private final String extension;
|
||||
private VideoCodec[] supportedCodecs = null;
|
||||
|
||||
VideoContainer(String text, String extension) {
|
||||
this.text = text;
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String text() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public String extension() {
|
||||
return extension;
|
||||
}
|
||||
|
||||
public VideoCodec[] getSupportedCodecs() {
|
||||
if (this.supportedCodecs == null) {
|
||||
List<VideoCodec> supportedCodecs = new ArrayList<>();
|
||||
try (AVOutputFormat outputFormat = avformat.av_guess_format(this.extension, "test."+this.extension, null)) {
|
||||
for (VideoCodec codec : VideoCodec.values()) {
|
||||
if (codec == VideoCodec.AV1 && this != VideoContainer.MP4) {
|
||||
continue;
|
||||
}
|
||||
if (codec.getEncoders().length == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int ret = avformat.avformat_query_codec(outputFormat, codec.codecId(), avcodec.FF_COMPLIANCE_NORMAL);
|
||||
if (ret == 1) {
|
||||
supportedCodecs.add(codec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.supportedCodecs = supportedCodecs.toArray(new VideoCodec[0]);
|
||||
}
|
||||
return this.supportedCodecs;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.moulberry.flashback.combo_options;
|
||||
|
||||
public enum VideoPreset implements ComboOption {
|
||||
|
||||
ULTRAFAST("Ultra Fast", "ultrafast"),
|
||||
SUPERFAST("Super Fast", "superfast"),
|
||||
VERYFAST("Very Fast", "veryfast"),
|
||||
FASTER("Faster", "faster"),
|
||||
FAST("Fast", "fast"),
|
||||
MEDIUM("Medium", "medium"),
|
||||
SLOW("Slow", "slow"),
|
||||
SLOWER("Slower", "slower"),
|
||||
VERYSLOW("Very Slow", "veryslow");
|
||||
|
||||
private final String text;
|
||||
private final String presetId;
|
||||
|
||||
VideoPreset(String text, String presetId) {
|
||||
this.text = text;
|
||||
this.presetId = presetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String text() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public String presetId() {
|
||||
return this.presetId;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user