-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server: Implement a better accelerator architecture.
Also added hardware decoding.
- Loading branch information
Showing
10 changed files
with
338 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
server/src/main/java/xyz/e3ndr/athena/transcoding/CommandBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package xyz.e3ndr.athena.transcoding; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import lombok.NonNull; | ||
|
||
public class CommandBuilder { | ||
private List<String> args = new LinkedList<>(); | ||
|
||
public CommandBuilder add(@NonNull String... args) { | ||
for (String a : args) { | ||
this.args.add(a); | ||
} | ||
return this; | ||
} | ||
|
||
public CommandBuilder add(@NonNull List<String> args) { | ||
this.args.addAll(args); | ||
return this; | ||
} | ||
|
||
public List<String> asList() { | ||
return this.args; | ||
} | ||
|
||
} |
109 changes: 34 additions & 75 deletions
109
server/src/main/java/xyz/e3ndr/athena/transcoding/FFMpegArgs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
server/src/main/java/xyz/e3ndr/athena/transcoding/accelerator/Accelerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package xyz.e3ndr.athena.transcoding.accelerator; | ||
|
||
import java.util.List; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import lombok.NonNull; | ||
import xyz.e3ndr.athena.types.VideoCodec; | ||
import xyz.e3ndr.athena.types.VideoQuality; | ||
|
||
public interface Accelerator { | ||
|
||
public @Nullable List<String> acc_getFF(); | ||
|
||
public @Nullable List<String> v_getFF(@NonNull VideoCodec codec, @NonNull VideoQuality quality); | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
server/src/main/java/xyz/e3ndr/athena/transcoding/accelerator/NvidiaPreferred.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package xyz.e3ndr.athena.transcoding.accelerator; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import lombok.NonNull; | ||
import xyz.e3ndr.athena.types.VideoCodec; | ||
import xyz.e3ndr.athena.types.VideoQuality; | ||
|
||
class NvidiaPreferred implements Accelerator { | ||
|
||
@Override | ||
public @Nullable List<String> acc_getFF() { | ||
return null; // TODO some good logic for this so we can accelerate decoding. | ||
// return Arrays.asList( | ||
// "-hwaccel", "cuda", | ||
// "-hwaccel_output_format", "cuda" | ||
// ); | ||
} | ||
|
||
@Override | ||
public @Nullable List<String> v_getFF(@NonNull VideoCodec codec, @NonNull VideoQuality quality) { | ||
switch (codec) { | ||
case H264_BASELINE: | ||
return Arrays.asList( | ||
"-c:v", "h264_nvenc", | ||
"-profile:v", "baseline", | ||
"-pix_fmt", "yuv420p" | ||
); | ||
|
||
case H264_HIGH: | ||
return Arrays.asList( | ||
"-c:v", "h264_nvenc", | ||
"-profile:v", "high", | ||
"-pix_fmt", "yuv420p", | ||
"-level", "5.0", | ||
"-preset", "slow" | ||
); | ||
|
||
// TODO the more advanced parameters for HEVC and AV1 | ||
case HEVC: | ||
return Arrays.asList( | ||
"-c:v", "hevc_nvenc" | ||
); | ||
|
||
case AV1: | ||
return Arrays.asList( | ||
"-c:v", "av1_nvenc" | ||
); | ||
|
||
default: | ||
return null; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.