Skip to content

Commit

Permalink
still couldn't fix but this is better to use imo
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagabe19 committed Nov 1, 2024
1 parent c576765 commit ae6d98f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
15 changes: 6 additions & 9 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7033,7 +7033,7 @@ class PlayState extends MusicBeatState

private function initRender():Void
{
if (!FileSystem.exists(#if linux 'ffmpeg' #elseif mobile lime.system.System.applicationStorageDirectory + 'ffmpeg' #else 'ffmpeg.exe' #end))
if (!FileSystem.exists(#if linux 'ffmpeg' #elseif mobile android.content.Context.getFilesDir() + '/ffmpeg' #else 'ffmpeg.exe' #end))
{
trace("\"FFmpeg\" not found! (Is it in the same folder as JSEngine?)");
return;
Expand All @@ -7052,20 +7052,16 @@ class PlayState extends MusicBeatState
ffmpegExists = true;

#if android
lime.system.JNI.createStaticMethod('org/libsdl/app/SDLActivity', 'nativeSetenv', '(Ljava/lang/String;Ljava/lang/String;)V')("LD_LIBRARY_PATH", lime.system.System.applicationStorageDirectory);
lime.system.JNI.createStaticMethod('org/libsdl/app/SDLActivity', 'nativeSetenv', '(Ljava/lang/String;Ljava/lang/String;)V')("LD_LIBRARY_PATH", android.content.Context.getFilesDir());
#end
process = new Process(#if android lime.system.System.applicationStorageDirectory
+ #end 'ffmpeg', [
process = new Process(#if android '${android.content.Context.getFilesDir()}/ffmpeg' #else 'ffmpeg' #end, [
'-v',
'quiet',
'-y',
'-f',
'rawvideo',
'-pix_fmt',
'rgba',
/*#if mobile
'-vf', 'crop=trunc(iw/2)*2:trunc(ih/2)*2',
#end*/
'-s',
lime.app.Application.current.window.width + 'x' + lime.app.Application.current.window.height,
'-r',
Expand All @@ -7076,19 +7072,20 @@ class PlayState extends MusicBeatState
ClientPrefs.vidEncoder,
'-b:v',
Std.string(ClientPrefs.renderBitrate * 1000000),
'assets/gameRenders/' + Paths.formatToSongPath(SONG.song) + '.mp4' /*#if android + "&" #end*/
'assets/gameRenders/' + Paths.formatToSongPath(SONG.song) + '.mp4'
]);
FlxG.autoPause = false;
}

private function pipeFrame():Void
{
if (!ffmpegExists || process == null)
return;
return;

var img = lime.app.Application.current.window.readPixels(new lime.math.Rectangle(FlxG.scaleMode.offset.x, FlxG.scaleMode.offset.y, FlxG.scaleMode.gameSize.x, FlxG.scaleMode.gameSize.y));
var bytes = img.getPixels(new lime.math.Rectangle(0, 0, img.width, img.height));
process.stdin.writeBytes(bytes, 0, bytes.length);
//process.stdin.flush();
}

public static function stopRender():Void
Expand Down
6 changes: 3 additions & 3 deletions source/mobile/CopyState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class CopyState extends MusicBeatState
#if android
for (ffmpegFile in ["ffmpeg", "libavcodec.so", "libavfilter.so", "libavformat.so", "libavutil.so", "libffmpeg.so", "libswresample.so", "libswscale.so"])
{
if (!FileSystem.exists(lime.system.System.applicationStorageDirectory + ffmpegFile))
if (!FileSystem.exists(android.content.Context.getFilesDir() + '/$ffmpegFile'))
{
File.saveBytes(lime.system.System.applicationStorageDirectory + ffmpegFile, getFileBytes(getFile(ffmpegFile)));
Sys.command('chmod', ['755', lime.system.System.applicationStorageDirectory + ffmpegFile]);
File.saveBytes(android.content.Context.getFilesDir() + '/$ffmpegFile', getFileBytes(getFile(ffmpegFile)));
Sys.command('chmod', ['755', android.content.Context.getFilesDir() + '/$ffmpegFile']);
}
}
#end
Expand Down

0 comments on commit ae6d98f

Please sign in to comment.