Skip to content

Commit

Permalink
feat(video): enable CS2 video generation on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
akiver committed Aug 19, 2024
1 parent 82a3bfd commit 9f18a93
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/node/video/ffmpeg/generate-video-with-ffmpeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function getFFmpegArgs(settings: GenerateVideoWithFFmpegSettings) {
args.push(
`-i "${rawFilesPathPattern}"`,
`-i "${wavFilePath}"`,
`-vcodec ${videoCodec}`,
`-vcodec ${videoCodec} -pix_fmt yuv420p`,
`-crf ${constantRateFactor}`,
`-acodec ${audioCodec}`,
`-b:a ${audioBitrate}K`,
Expand Down
11 changes: 6 additions & 5 deletions src/node/video/sequences/move-sequences-raw-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ import { WavFileNotFound } from 'csdm/node/video/errors/wav-file-not-found';
// - CS2 because it's not yet possible with HLAE to set the destination folder and the startmovie command place the
// files in a "movie" folder (we can't change it).
export async function moveSequencesRawFiles(sequences: Sequence[], destinationFolderPath: string, game: Game) {
if (isWindows && game === Game.CSGO) {
const isCsgo = game === Game.CSGO;
if (isWindows && isCsgo) {
return;
}

const csgoFolderPath = await getCsgoFolderPathOrThrow(game);
let recordingFolderPath: string;
if (isWindows) {
if (isCsgo) {
recordingFolderPath = path.join(csgoFolderPath, 'csgo');
} else {
// The "movie" folder is inside our plugin folder
recordingFolderPath = path.join(csgoFolderPath, 'game', 'csgo', 'csdm', 'movie');
} else {
recordingFolderPath = path.join(csgoFolderPath, 'csgo');
}

const recordingFolderExists = await fs.pathExists(recordingFolderPath);
Expand Down Expand Up @@ -61,7 +62,7 @@ export async function moveSequencesRawFiles(sequences: Sequence[], destinationFo
const rawFilesFolderPath = path.dirname(tgaFiles[0]);
logger.log(`Sequence raw files folder: ${rawFilesFolderPath}`);

const wavFilePath = path.join(rawFilesFolderPath, isWindows ? `${sequenceName}.wav` : `${sequenceName}.WAV`);
const wavFilePath = path.join(rawFilesFolderPath, isCsgo ? `${sequenceName}.WAV` : `${sequenceName}.wav`);
if (!(await fs.pathExists(wavFilePath))) {
throw new WavFileNotFound();
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/hooks/use-counter-strike.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function isVideoGenerationAvailable(game: Game) {
return true;
}

return window.csdm.isWindows;
return !window.csdm.isMac;
}

export function useCounterStrike() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,24 @@ export function EditSequenceSettingsDialog() {
</div>
</CollapseTransition>
</div>
<div className="flex flex-col gap-y-4">
<Checkbox
label={<Trans>Override death notices</Trans>}
isChecked={state.overrideDeathNotices}
onChange={(event) => {
setState({ ...state, overrideDeathNotices: event.target.checked });
}}
/>

<CollapseTransition isVisible={state.overrideDeathNotices}>
<div className="max-h-[300px] overflow-y-auto">
<DeathNotices />
</div>
</CollapseTransition>
</div>
{window.csdm.isWindows && (
<div className="flex flex-col gap-y-4">
<Checkbox
label={<Trans>Override death notices</Trans>}
isChecked={state.overrideDeathNotices}
onChange={(event) => {
setState({ ...state, overrideDeathNotices: event.target.checked });
}}
/>

<CollapseTransition isVisible={state.overrideDeathNotices}>
<div className="max-h-[300px] overflow-y-auto">
<DeathNotices />
</div>
</CollapseTransition>
</div>
)}
</div>
</DialogContent>
<DialogFooter>
Expand Down
16 changes: 1 addition & 15 deletions src/ui/match/video/video-loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { useCurrentMatch } from '../use-current-match';
import type { InitializeVideoPayload } from 'csdm/server/handlers/renderer-process/video/initialize-video-handler';
import { ErrorCode } from 'csdm/common/error-code';
import { isErrorCode } from 'csdm/common/is-error-code';
import { isVideoGenerationAvailable } from 'csdm/ui/hooks/use-counter-strike';

export function VideoLoader() {
const client = useWebSocketClient();
Expand All @@ -21,13 +20,8 @@ export function VideoLoader() {
const dispatch = useDispatch();
const [isReady, setIsReady] = useState(false);
const demoExists = usePathExists(match.demoFilePath);
const isSupported = isVideoGenerationAvailable(match.game);

useEffect(() => {
if (!isSupported) {
return;
}

const initialize = async () => {
try {
const payload: InitializeVideoPayload = {
Expand All @@ -47,7 +41,7 @@ export function VideoLoader() {
};

initialize();
}, [dispatch, client, match, isSupported]);
}, [dispatch, client, match]);

if (errorCode) {
let message: ReactNode;
Expand All @@ -65,14 +59,6 @@ export function VideoLoader() {
return <Message message={message} />;
}

if (!isSupported) {
return (
<Message
message={<Trans>The video generator is currently available only on Windows for Counter-Strike 2 demos.</Trans>}
/>
);
}

if (!isReady) {
return <Message message={<Trans>Loading video generator…</Trans>} />;
}
Expand Down
4 changes: 0 additions & 4 deletions src/ui/translations/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5152,10 +5152,6 @@ msgstr "This demo checksum doesn't match the one associated with the match."
msgid "An error occurred. (Code {errorCode})"
msgstr "An error occurred. (Code {errorCode})"

#: src/ui/match/video/video-loader.tsx
msgid "The video generator is currently available only on Windows for Counter-Strike 2 demos."
msgstr "The video generator is currently available only on Windows for Counter-Strike 2 demos."

#: src/ui/match/video/video-loader.tsx
msgid "Loading video generator…"
msgstr "Loading video generator…"
Expand Down
4 changes: 0 additions & 4 deletions src/ui/translations/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5157,10 +5157,6 @@ msgstr ""
msgid "An error occurred. (Code {errorCode})"
msgstr ""

#: src/ui/match/video/video-loader.tsx
msgid "The video generator is currently available only on Windows for Counter-Strike 2 demos."
msgstr ""

#: src/ui/match/video/video-loader.tsx
msgid "Loading video generator…"
msgstr ""
Expand Down
4 changes: 0 additions & 4 deletions src/ui/translations/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5157,10 +5157,6 @@ msgstr "Le checksum de cette démo ne correspond pas à celui du match associé.
msgid "An error occurred. (Code {errorCode})"
msgstr "Une erreur est survenue. (Code {errorCode})"

#: src/ui/match/video/video-loader.tsx
msgid "The video generator is currently available only on Windows for Counter-Strike 2 demos."
msgstr "Le générateur de vidéos est actuellement disponible uniquement sur Windows pour les démos Counter-Strike 2."

#: src/ui/match/video/video-loader.tsx
msgid "Loading video generator…"
msgstr "Chargement du générateur de vidéos…"
Expand Down
4 changes: 0 additions & 4 deletions src/ui/translations/pt-BR/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5157,10 +5157,6 @@ msgstr ""
msgid "An error occurred. (Code {errorCode})"
msgstr ""

#: src/ui/match/video/video-loader.tsx
msgid "The video generator is currently available only on Windows for Counter-Strike 2 demos."
msgstr ""

#: src/ui/match/video/video-loader.tsx
msgid "Loading video generator…"
msgstr "Carregando gerador de vídeo…"
Expand Down
4 changes: 0 additions & 4 deletions src/ui/translations/zh-CN/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5157,10 +5157,6 @@ msgstr "此demo校验与比赛信息不匹配"
msgid "An error occurred. (Code {errorCode})"
msgstr "发生了错误(错误代码 {errorCode})"

#: src/ui/match/video/video-loader.tsx
msgid "The video generator is currently available only on Windows for Counter-Strike 2 demos."
msgstr "视频生成器目前仅适用于 Windows 系统中的Counter-Strike 2 录像."

#: src/ui/match/video/video-loader.tsx
msgid "Loading video generator…"
msgstr "正在加载视频生成器…"
Expand Down
4 changes: 0 additions & 4 deletions src/ui/translations/zh-TW/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5157,10 +5157,6 @@ msgstr ""
msgid "An error occurred. (Code {errorCode})"
msgstr ""

#: src/ui/match/video/video-loader.tsx
msgid "The video generator is currently available only on Windows for Counter-Strike 2 demos."
msgstr ""

#: src/ui/match/video/video-loader.tsx
msgid "Loading video generator…"
msgstr ""
Expand Down

0 comments on commit 9f18a93

Please sign in to comment.