Open pawegio opened 4 years ago
I think so, many components expect audio to be either 1 or 2 channels.
But when i try to compress some videos, it gets failed. What to do?
Can you upload the file?
The vidoe link is "https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_30mb.mp4" The channel count shows as 6 as error
Just released v0.11.2 with a fix. v0.11.2 allows videos with more than 2 channels, as you don't try to change the number of channels to something else (we still don't support downmix and upmix for 3+ channels).
Note, the fix does not work on on API23 emulator, I'm not sure whether it's emulator only or on real devices too. API24 and newer work well.
@natario1 Getting this. Any reason for it?
V/MediaMetadataRetriever( 7605): extractMetadata(9) I/Reader ( 7605): Returning State.Wait because source can't read VIDEO right now. I/VideoEncoder( 7605): Can't dequeue output buffer: INFO_TRY_AGAIN_LATER
These logs are normal
I am uploading video after compression. Previous: This channel count 6 video was throwing error at first Now: It is running for infinite and never finishes.
There's a test that transcodes this file successfully. What parameters are you using?
I am using default params mostly.
val videoTrackStrategy = DefaultVideoStrategy.Builder()
.keyFrameInterval(3f)
.bitRate(1280 * 720 * 4.toLong())
.frameRate(frameRate!!) // will be capped to the input frameRate
.build()
audioTrackStrategy = if (includeAudio) {
val sampleRate = DefaultAudioStrategy.SAMPLE_RATE_AS_INPUT
val channels = DefaultAudioStrategy.CHANNELS_AS_INPUT
DefaultAudioStrategy.builder()
.channels(channels)
.sampleRate(sampleRate)
.build()
} else {
RemoveTrackStrategy()
}
val dataSource = if (startTime != null || duration != null){
val source = UriDataSource(context, Uri.parse(path))
TrimDataSource(source, (1000 * 1000 * (startTime ?: 0)).toLong(), (1000 * 1000 * (duration ?: 0)).toLong())
}else{
UriDataSource(context, Uri.parse(path))
}
transcodeFuture = Transcoder.into(destPath!!)
.addDataSource(dataSource)
.setAudioTrackStrategy(audioTrackStrategy)
.setVideoTrackStrategy(videoTrackStrategy)
.setListener(object : TranscoderListener {
override fun onTranscodeProgress(progress: Double) {
channel.invokeMethod("updateProgress", progress * 100.00)
}
override fun onTranscodeCompleted(successCode: Int) {
channel.invokeMethod("updateProgress", 100.00)
val json = Utility(channelName).getMediaInfoJson(context, destPath)
json.put("isCancel", false)
result.success(json.toString())
if (deleteOrigin) {
File(path).delete()
}
}
override fun onTranscodeCanceled() {
result.success(null)
}
override fun onTranscodeFailed(exception: Throwable) {
result.success(null)
}
}).transcode()
Maybe something is missing there. I'm using this code and it works (even without ClipDataSource):
val dataSource = input("bbb_720p_30mb.mp4")
val videoTrackStrategy = DefaultVideoStrategy.Builder()
.keyFrameInterval(3f)
.bitRate(1280 * 720 * 4.toLong())
.frameRate(30)
.build()
val audioTrackStrategy = DefaultAudioStrategy.builder()
.channels(DefaultAudioStrategy.CHANNELS_AS_INPUT)
.sampleRate(DefaultAudioStrategy.SAMPLE_RATE_AS_INPUT)
.build()
addDataSource(ClipDataSource(dataSource, 0, 5_000_000))
setAudioTrackStrategy(audioTrackStrategy)
setVideoTrackStrategy(videoTrackStrategy)
Transcoder throws
UnsupportedOperationException
, when I'm trying to transcode video with 6 audio channels. Is it a real engine limitation?