SimformSolutionsPvtLtd / SSffmpegVideoOperation

This is a library of FFmpeg for android... 📸 🎞 🚑
Apache License 2.0
355 stars 85 forks source link

Add Text to Image #38

Open daliborristic883 opened 2 years ago

daliborristic883 commented 2 years ago

Describe the bug I changed AddTextOnVideo feature to add text on Image. Here are queries. but when I run this command, I can see error ffmpeg error initializing filter 'drawtext' with args Please help me Screenshot 2022-04-19 at 12 45 24 PM

This is my sample code.

private fun addTextProcess(imagePath: String) {
        val outputPath = Common.getFilePath(this, Common.IMAGE)
        val dateString = Date().dateToString("yyyy-MM-dd HH:mm:ss.SSS")
        val fontPath = Common.getFileFromAssets(this, "roboto_regular.ttf").absolutePath
        val query = ffmpegQueryExtension.addTextOnVideo(imagePath, dateString,
            0.0f,
            0.0f,
            fontPath = fontPath,
            isTextBackgroundDisplay = false,
            fontSize = 30,
            fontcolor = "red",
            output = outputPath
        )
        CallBackOfQuery().callQuery(query, object : FFmpegCallBack {
            override fun process(logMessage: LogMessage) {
                Log.d("Dalibor", logMessage.text)
            }

            override fun success() {
               Log.d("Dalibor", "Sucess")
            }

            override fun cancel() {
                addTimeStampToPhotos()
            }

            override fun failed() {
                addTimeStampToPhotos()
            }
        })
    }
AshvinVavaliya commented 2 years ago

@daliborristic883 Issue is here, "drawtext=............:x=0.0:y=0.0:..........." Please give value of X and Y for the calculation of X and Y value, get height and width of Image and convert into percentage form ex. Image have height = 100% and width = 100% and I want to display text in center then give value X=50.0% and Y=50.0%