yetCalc icon indicating copy to clipboard operation
yetCalc copied to clipboard

Video/audio duration converter depending on playback speed coefficient

Open neilcrownis opened this issue 1 year ago • 1 comments

Maybe I'm weird, maybe there are a lot of people like me, but.... I need functionality to calculate the duration of a video or audio taking into account the playback speed. I even wrote a rough version of such code and would like to suggest adding it to the application.

This is my implementation of this idea in clear kotlin:

import java.util.Scanner

class VideoDuration(
    var hours: Int = 0,
    var minutes: Int = 0,
    var seconds: Int = 0,
    var playbackSpeed: Double = 1.0
) {
    fun totalDurationInSeconds(): Int {
        return hours * 3600 + minutes * 60 + seconds
    }

    fun adjustedDuration(): Double {
        val totalSeconds = totalDurationInSeconds()
        return totalSeconds / playbackSpeed
    }

    fun displayAdjustedDuration() {
        val adjustedSeconds = adjustedDuration()
        val adjustedHours = (adjustedSeconds / 3600).toInt()
        val adjustedMinutes = ((adjustedSeconds % 3600) / 60).toInt()
        val adjustedSecondsFinal = (adjustedSeconds % 60).toInt()

        println("Adjusted duration: $adjustedHours hours, $adjustedMinutes minutes, $adjustedSecondsFinal seconds")
    }
}

fun main() {
    val scanner = Scanner(System.`in`)

    println("Enter the duration of the video:")
    print("Hours: ")
    val hours = scanner.nextInt()
    print("Minutes: ")
    val minutes = scanner.nextInt()
    print("Seconds: ")
    val seconds = scanner.nextInt()

    print("Enter the playback speed (e.g., 1.5 for 1.5x): ")
    val playbackSpeedInput = scanner.next() // Read as a string
    val playbackSpeed = playbackSpeedInput.replace(',', '.').replace("x", "").toDouble() // Clean input and convert to double

    val video = VideoDuration(hours, minutes, seconds, playbackSpeed)
    video.displayAdjustedDuration()
}

neilcrownis avatar May 07 '25 16:05 neilcrownis

Maybe I'm weird, maybe there are a lot of people like me, but....

Nah, its fine

I need functionality to calculate the duration of a video or audio taking into account the playback speed. I even wrote a rough version of such code and would like to suggest adding it to the application.

😂sure, I did not expect such a feature request, but yea yetCalc has a Calculator, a Converter and a programmer mode too, so why not this too, nothing wrong with this request, well I have wanted to add a date conversion mode too, so maybe in the future, the app might have 5 modes, who knows ;).

Yet-Zio avatar Oct 28 '25 11:10 Yet-Zio