arthenica / ffmpeg-kit

FFmpeg Kit for applications. Supports Android, Flutter, iOS, Linux, macOS, React Native and tvOS. Supersedes MobileFFmpeg, flutter_ffmpeg and react-native-ffmpeg.
https://arthenica.github.io/ffmpeg-kit
GNU Lesser General Public License v3.0
4.24k stars 570 forks source link

react-native iOS: undefined returnCode / failStackTrace 2 #1006

Closed illlama closed 1 month ago

illlama commented 1 month ago

Description I'm trying to use simple method that copy video that I recorded in another library. But the session.getReturnCode() and session.getFailStackTrace() returns undefined always. I know there's a closed same issue but there isn't answer I wanted.

Expected behavior return some returnCode and I hope to get a output too.

Current behavior

  const videoUri = params.url;           // /private/var/mobile/Containers/Data/Application/D4C2858B-6132-4A20-A11C-49D9448D4CA4/tmp/viro_media/lyd7lh1dkgs0x.mp4
  const outputUri = `${RNFS.DocumentDirectoryPath}/output_video.mp4`;        // /var/mobile/Containers/Data/Application/D4C2858B-6132-4A20-A11C-49D9448D4CA4/Documents/output_video.mp4

const ffmpegCommand = `-i "${videoUri}" -c copy "${outputUri}"`;

FFmpegKit.executeAsync(ffmpegCommand)
        .then(async (session) => {
          const returnCode = await session.getReturnCode();
          const state = await session.getState();
          const failStackTrace = await session.getFailStackTrace();
          const output = await session.getOutput();
          const logs = await session.getLogs();

          console.log('=====FFmpegKit.execute=====');
          console.log('returnCode', returnCode);
          console.log('state', state);
          console.log('failStackTrace', failStackTrace);
          console.log('output', output);
          console.log('logs', logs);
        })
        .catch((error) => {
          console.log(error);
        });

To Reproduce simplify a ffmpegCommand (I wanted to make a watermark on video)

Screenshots If applicable, add screenshots to help explain your problem.

Logs

 LOG  =====FFmpegKit.execute=====
 LOG  returnCode undefined
 LOG  state 1
 LOG  failStackTrace undefined
 LOG  output
 LOG  logs []

Environment

illlama commented 1 month ago
      const session = await FFmpegKit.executeAsync(ffmpegCommand);

      const monitorSession = async (session: FFmpegSession) => {
        while (true) {
          const state = await session.getState();
          const returnCode = await session.getReturnCode();
          console.log(`FFmpegKit session state: ${state}, returnCode: ${returnCode}`);
          if (state !== 1) {
            return { returnCode, state };
          }
          await new Promise((resolve) => setTimeout(resolve, 1000));
        }
      };

      const { returnCode, state } = await monitorSession(session);

I waited session to finish it's work.