Skip to content

Commit eb5f932

Browse files
committed
added source / output fps
1 parent 9897b26 commit eb5f932

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

app/src/main/java/com/exozet/videoeditor/demo/MainActivity.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,20 @@ class MainActivity : AppCompatActivity() {
139139
frameFolder = frameFolder,
140140
outputUri = outputVideo,
141141
config = EncodingConfig(
142-
sourceFrameRate = 30 // translates into every input image is a frame in new video
143-
)
142+
sourceFrameRate = 120f / 63f,
143+
outputFrameRate = 30f
144+
),
145+
deleteFramesOnComplete = false
144146
).subscribeOn(Schedulers.computation())
145147
.observeOn(AndroidSchedulers.mainThread())
146148
.subscribe({
147-
logv { "extract frames ${it.progress} ${it.message} ${(it.duration / 1000f).roundToInt()} s" }
149+
150+
merge_frames_progress.show()
151+
merge_frames_progress.progress = it.progress
152+
153+
logv { "extract frames $it" }
154+
155+
output.text = "${(it.duration / 1000f).roundToInt()} s ${it.message?.trimMargin()}\n${output.text}"
148156

149157
}, {
150158
logv { "creating video fails ${it.message}" }

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
android:layout_marginStart="64dp"
6363
android:layout_marginEnd="64dp"
6464
android:visibility="gone"
65-
app:layout_constraintBottom_toTopOf="@id/stop_process"
65+
app:layout_constraintBottom_toTopOf="@id/transcode_video"
6666
app:layout_constraintEnd_toEndOf="parent"
6767
app:layout_constraintStart_toStartOf="parent"
6868
app:layout_constraintTop_toBottomOf="@id/make_video"

videoeditor/src/main/java/com/exozet/videoeditor/EncodingConfig.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,18 @@ data class EncodingConfig(
5555
*/
5656
@IntRange(from = 0, to = 63)
5757
val videoQuality: Int? = null,
58+
5859
/**
59-
* -r Frame rate of the video.
60+
* -framerate input Frame rate of the video.
6061
* https://lists.ffmpeg.org/pipermail/ffmpeg-user/2013-July/016273.html
6162
*/
62-
val sourceFrameRate: Int? = null,
63+
val sourceFrameRate: Float? = 30000f/1001f,
64+
65+
/**
66+
* -r output Frame rate of the video.
67+
* https://video.stackexchange.com/a/13074
68+
*/
69+
val outputFrameRate: Float? = 30000f/1001f,
6370

6471
/**
6572
* pix_fmts

videoeditor/src/main/java/com/exozet/videoeditor/FFMpegTranscoder.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,17 @@ object FFMpegTranscoder {
248248
add("-y")
249249

250250
config.sourceFrameRate?.let {
251-
add("-r"); add("${config.sourceFrameRate}")
251+
add("-framerate"); add("${config.sourceFrameRate}")
252252
}
253253

254254
add("-threads"); add("${Runtime.getRuntime().availableProcessors()}")
255+
255256
add("-i"); add("${frameFolder.path}/image_%03d.jpg")
257+
258+
add("-r"); add("${config.outputFrameRate}")
259+
256260
add("-c:v"); add("${config.encoding}")
257-
add("-x264opts"); add("keyint=${config.keyInt}:min-keyint=${config.minKeyInt}:no-scenecut")
261+
// add("-x264opts"); add("keyint=${config.keyInt}:min-keyint=${config.minKeyInt}:no-scenecut")
258262

259263
config.gopValue?.let {
260264
add("-g"); add("${config.gopValue}")

0 commit comments

Comments
 (0)