Skip to content

getSafParameterForWrite doesn't work with -movflags faststart on Android #167

Closed
@gazlaws-dev

Description

Description
Creating an output video (.mp4) with the-movflags faststart doesn't work with getSafParameterForWrite (using Android's Storage Access Framework), presumably because it's not able to read the file for the second pass.

Expected behavior
An option to create the output file with read and write permissions. Maybe getSafParameter can be made public so we can pass 'rw' as openMode.

Current behavior
Output file is not created properly, error shown:

2021-10-03 15:27:24.849 24442-24657/x I/ffmpeg-kit: Output #0, mp4, to 'saf:105.mp4':
2021-10-03 15:27:28.770 24442-24657/x E/ffmpeg-kit: Error writing trailer of saf:105.mp4: Bad file descriptor

To Reproduce

inputVideoUrl = FFmpegKitConfig.getSafParameterForRead(requireContext(), inputVideoUri);
outputFilePath = FFmpegKitConfig.getSafParameterForWrite(requireContext(), resultVideoUri);

ffmpeg command (shortened):
  -y -i "saf:90.mp4" -vcodec libx264  -movflags faststart  saf:105.mp4

Logs

2021-10-03 15:27:18.726 24442-24442/x I/EditFragment: getContent: Input video absolute file path: saf:90.mp4
2021-10-03 15:27:24.547 24442-24657/x I/ffmpeg-kit: Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'saf:90.mp4':
2021-10-03 15:27:24.849 24442-24657/x I/ffmpeg-kit: Output #0, mp4, to 'saf:105.mp4':
2021-10-03 15:27:28.770 24442-24657/x E/ffmpeg-kit: Error writing trailer of saf:105.mp4: Bad file descriptor

Environment

  • Platform: Android
  • Architecture: arm64-v8a
  • Version: v4.5

Metadata

Assignees

Labels

androidAffect Android platformenhancementNew feature or requestfixed-in-v4.5.1libraryAffects the librarysafIssue about storage access frameworkv4.4Affects v4.4 releasev4.5Affects v4.5 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions