Understanding How to Capture Exceptions When Using ffmpeg on Android

Asked 2 years ago, Updated 2 years ago, 117 views

I am thinking of creating and using libvideokit.so by referring to the following site. http://qiita.com/hayabon/items/3a0817b4443bd0e4c5af

If there is no file to specify in the execution command, the application will drop. Is it possible for the app to capture this and display "Error Occurred"?

Thank you for your advice.

01-08 14:26:01.490:I/Videookit (14692):Initializing AV codecs
01-08 14:26:01.500:I/Videookit (14692): Splitting the commandline.
01-08 14:26:01.500: I/Videookit (14692): Reading option '-y'...
01-08 14:26:01.500: I/Videookit (14692): matched as option 'y' (overwrite output files) with argument '1'.
01-08 14:26:01.500: I/Videookit (14692): Reading option '-f'...
01-08 14:26:01.500: I/Videookit (14692): matched as option 'f' (force format) with argument 'image2'.
01-08 14:26:01.500: I/Videookit (14692): Reading option '-loop'...
01-08 14:26:01.500: I/Videookit (14692): matched as AVOption 'loop' with argument '1'.
01-08 14:26:01.500: I/Videookit (14692): Reading option '-i'...
01-08 14:26:01.500: I/Videookit(14692): matched as input file with argument '/data/data/com.example.img2video/files/movie_0001.jpg'.
01-08 14:26:01.500: I/Videookit (14692): Reading option '-vcodec'...
01-08 14:26:01.500: I/Videookit(14692): matched as option 'vcodec' (force video codec('copy' to copy stream)) with argument 'mpeg4'.
01-08 14:26:01.500: I/Videookit (14692): Reading option '-t'...
01-08 14:26:01.500: I/Videookit (14692): matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '3'.
01-08 14:26:01.500: I/Videookit (14692): Reading option '-r'...
01-08 14:26:01.500: I/Videookit (14692): matched as option 'r' (set frame rate (Hz value, friction or deviation)) with argument '1'.
01-08 14:26:01.500: I/Videookit (14692): Reading option '-s'...
01-08 14:26:01.500: I/Videookit (14692): matched as option 's' (set frame size (WxHorabrevation)) with argument '640x360'.
01-08 14:26:01.500: I/Videookit (14692): Reading option '-preset'...
01-08 14:26:01.500: I/Videookit (14692): matched as AVOption 'preset' with argument 'ultrafast'.
01-08 14:26:01.500: I/Videookit (14692): Reading option '-tune'...
01-08 14:26:01.500: I/Videookit (14692): matched as AVOption 'tune' with argument 'stillimage'.
01-08 14:26:01.500: I/Videookit (14692): Reading option '/data/data/com.example.img2 video/files/1.mp4' ...
01-08 14:26:01.500:I/Videookit (14692)—Matched as output file.
01-08 14:26:01.500: I/Videookit (14692): Finished splitting the commandline.
01-08 14:26:01.500: I/Videookit (14692): Parsing a group of options: global.
01-08 14:26:01.500:I/Videookit(14692): Applying optiony(overwrite output files) with argument 1.
01-08 14:26:01.500: I/Videookit (14692): Successfully parsed a group of options.
01-08 14:26:01.500:I/Videookit(14692):Parsing a group of options: input file/data/data/com.example.img2video/files/movie_0001.jpg.
01-08 14:26:01.500: I/Videookit (14692): Applying option f(force format) with argument image 2.
01-08 14:26:01.500: I/Videookit (14692): Successfully parsed a group of options.
01-08 14:26:01.500:E/Videookit (14692): /data/data/com.example.img2 video/files/movie_0001.jpg: No such file or directory
01-08 14:26:01.500:E/Videookit (14692): Option loop not found.
01-08 14:26:01.510:A/libc(14692):Fatal signal11(SIGSEGV) at 0x00000018(code=1), thread14692(ample.img2video)

android ffmpeg

2022-09-30 17:33

2 Answers

Instead of using Videookit's void run(), why don't you run ffmpeg using ProcessBuilder?

//ffmpeg command string for execution
ProcessBuilder ffmpeg = new ProcessBuilder ("ffmpeg", ...);
Process ffmpeg_process=ffmpeg.start();
ffmpeg_process.waitFor();
int exit_status=ffmpeg_process.exitValue();
if(exit_status!=0){
  // error handling
}

If the ffmpeg command terminates abnormally, it is assumed that it returns a non-zero exit status.


2022-09-30 17:33

I think it's safe to check the existence of the file on your app side in advance.

According to Reference, you are using m4fg/android-ffmpeg-x264, but as far as the Java layer API:void run(String args) returns to the FFmpeg command and the atmosphere wrapper.I don't think so.


2022-09-30 17:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.