Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add intent for encoding file #70

Merged
merged 8 commits into from
Apr 1, 2018
Merged

Add intent for encoding file #70

merged 8 commits into from
Apr 1, 2018

Conversation

brarcher
Copy link
Owner

@brarcher brarcher commented Apr 1, 2018

This adds an intent to the app which can be used to request that a file be encoded without selecting options. The intent is called protect.videotranscoder.ENCODE, and takes the following arguments:

String inputVideoFilePath: Path to input video file
String outputFilePath: Path to output video/audio file
String mediaContainer: The output media container. Examples: flv, mkv, mp4, gif, mp3, ogg

If the media container supports video, the following are required:
String videoCodec: Video codec to use, must be supported by media container. Example: h264, mpeg4, mpeg2video, gif
Integer videoBitrateK: Bitrate to use for video stream, in 1000s of bits per second. Example: 2000
String resolution: Screen resolution of video stream. Example: 270x460
String fps: Frame per second. Can be an integer or floating number. Examples: 25, 19.01.

If the media container supports audio, the following are required:
String audioCodec: Audio codec to use, must be supported by media container. Example: aac, vorbis, mp3, none (ignores audio).
Integer audioSampleRate: Samples per second. Example: 22050
Integer audioBitrateK: Bitrate used for audio stream, in 1000s of bits per second. Example: 128.
String audioChannel: Number of channels used for audio. Example: 1, 2.

Example of encoding a video:

adb shell am start -a "protect.videotranscoder.ENCODE" --es inputVideoFilePath "/sdcard/ScreenRecord-2018-01-01-19-07-10.mp4" --es outputFilePath /sdcard/output.flv --es mediaContainer flv --es videoCodec h264 --ei videoBitrateK 2000 --es resolution 270x480 --es fps 19 --es audioCodec aac --ei audioSampleRate 22050 --ei audioBitrateK 100 --es audioChannel 2

This will result in a dialog asking for confirmation:

image

When encoding is complete a dialog is shown giving a summary and an option to send the file elsewhere:

image

This support should not be relied on and should be considered "alpha".

In addition, a simple shell script test is added which uses the intent interface to request several test files be encoded with various options.

One part, with no argument, will take the encode parameters
from the UI and use them. The second part will accept parameters
and start encoding. This change will be relevant soon when
an intent can also start encode, which provides its own
arguments.
ffprobe can output media info in json format, which makes
parsing easier and less brittle. As the the FFmpeg Android
library includes ffprobe, make use of it.
This is to allow for automated testing using the ENCODE
intent interface.
This test does not check all supported formats, and does not do
any validation on the encoded file to ensure it was what was
asked for. For now, all this test does is show that the arguments
were accepted and that something was produced.
@brarcher brarcher merged commit c4120d6 into master Apr 1, 2018
@brarcher brarcher deleted the intent branch April 1, 2018 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant