Page MenuHomePhabricator

[android] Implement transcodeVideo() function on Android
ClosedPublic

Authored by angelika on Thu, Mar 20, 4:45 AM.
Tags
None
Referenced Files
F5081070: D14478.diff
Sat, Mar 29, 4:29 AM
Unknown Object (File)
Fri, Mar 28, 1:17 PM
Unknown Object (File)
Fri, Mar 28, 6:02 AM
Unknown Object (File)
Wed, Mar 26, 3:10 PM
Unknown Object (File)
Wed, Mar 26, 1:55 AM
Unknown Object (File)
Tue, Mar 25, 10:03 PM
Unknown Object (File)
Tue, Mar 25, 2:20 PM
Unknown Object (File)
Mon, Mar 24, 2:09 PM
Subscribers

Details

Summary

https://linear.app/comm/issue/ENG-10314/migrate-comm-app-to-use-new-media-module

Changes:

  • on the native side we check progress every 200ms and send an event to the js side. The JS side then calls the callback with the progress
  • we can specify the profile and bitrate, we can't specify fps though
  • width and height is mandatory to keep it simple (ios requires it)
  • I'm returning some basic stats (speed, size and duration) but some are missing compared to ffmpeg implementation because I don't see much sense in collecting them. However I can add them if necessary (should be easy on Android, more complicated on iOS)

On Android there is no explicit way to set -movflags +faststart from ffmpeg. According to this question and github issue it's not supported.

Depends on D14477

Test Plan

Send some videos on some devices and verify they're transcoded correctly

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

angelika held this revision as a draft.
native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/media/MediaModule.kt
225 ↗(On Diff #47489)

We're setting the profile here, but it can be ignored by the encoder. Encoder probably knows better anyway.

243 ↗(On Diff #47489)

Run the timer to check progress every 200ms on the app thread. Start the transformer also on the app thread, because the transformer *must* always be accessed on the same thread. However the actual processing is done in some other internal thread, so we don't hang the app when processing.

native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/media/MediaModule.kt
188 ↗(On Diff #47489)

Which API is unstable here? It's worth adding an in-code comment

196 ↗(On Diff #47489)
285 ↗(On Diff #47489)

I'd parse second argument (Uri) at the beginning of the fun transcodeVideo() and do a null check in case caller provided invalid path/uri.
Now it can lead to crashing the app

bartek requested changes to this revision.Sun, Mar 23, 11:40 PM

Requesting changes because of these null checks which might lead to crash

This revision now requires changes to proceed.Sun, Mar 23, 11:40 PM
angelika marked an inline comment as done.
This revision is now accepted and ready to land.Wed, Mar 26, 3:08 AM