INDExOS / media-for-mobile

Media for Mobile
Other
456 stars 178 forks source link

[Sound issue] when Join video different sample-rate and channel-count #77

Open vfa-tuantt opened 6 years ago

vfa-tuantt commented 6 years ago

Hi, I'm working on this library and i found a big problem. When i try to join 2 video with difference sample-rate and channel, the first video is normal but another video sound has problem (slowly sound or fast sound). If you have any ideal please help me to resolve. Thanks alot This is 2 information of my videos:

File 1:

mediaFormat = {MediaFormat@11768} "{aac-profile=2, mime=audio/mp4a-latm, channel-count=2, max-input-size=723, durationUs=25054331, csd-0=java.nio.ByteArrayBuffer[position=0,limit=2,capacity=2], encoder-delay=1024, encoder-padding=0, sample-rate=44100}"
 mMap = {HashMap@11773}  size = 9
  0 = {HashMap$HashMapEntry@11777} "aac-profile" -> "2"
  1 = {HashMap$HashMapEntry@11778} "mime" -> "audio/mp4a-latm"
  2 = {HashMap$HashMapEntry@11779} "channel-count" -> "2"
  3 = {HashMap$HashMapEntry@11780} "max-input-size" -> "723"
  4 = {HashMap$HashMapEntry@11781} "durationUs" -> "25054331"
  5 = {HashMap$HashMapEntry@11782} "csd-0" -> "java.nio.ByteArrayBuffer[position=0,limit=2,capacity=2]"
  6 = {HashMap$HashMapEntry@11783} "encoder-delay" -> "1024"
  7 = {HashMap$HashMapEntry@11784} "encoder-padding" -> "0"
  8 = {HashMap$HashMapEntry@11785} "sample-rate" -> "44100"

File 2:

mediaFormat = {MediaFormat@11730} "{max-input-size=358, aac-profile=2, mime=audio/mp4a-latm, durationUs=4160000, csd-0=java.nio.ByteArrayBuffer[position=0,limit=2,capacity=2], channel-count=1, sample-rate=48000}"
 mMap = {HashMap@11735}  size = 7
  0 = {HashMap$HashMapEntry@11739} "max-input-size" -> "358"
  1 = {HashMap$HashMapEntry@11740} "aac-profile" -> "2"
  2 = {HashMap$HashMapEntry@11741} "mime" -> "audio/mp4a-latm"
  3 = {HashMap$HashMapEntry@11742} "durationUs" -> "4160000"
  4 = {HashMap$HashMapEntry@11743} "csd-0" -> "java.nio.ByteArrayBuffer[position=0,limit=2,capacity=2]"
  5 = {HashMap$HashMapEntry@11744} "channel-count" -> "1"
  6 = {HashMap$HashMapEntry@11745} "sample-rate" -> "48000"
 shadow$_klass_ = {Class@7519} "class android.media.MediaFormat"
 shadow$_monitor_ = -2017511570
milkywayriver commented 6 years ago

don't quite understand.when you say "video",do you mean "audio" ? because i see the MediaFormat was aac audio

vfa-tuantt commented 6 years ago

@milkywayriver After i joined successfully 2 video into 1 video with different sample-rate and channel-count, but the sound of video was not good. The sound is just like the video is playing in high speed, just like Minion is talking. If you have any idea please help me to resolve that. For example: Video 1 with info: Duration = 15s, sample-rate = 44100, channel-count = 2 Video 2 with info: Duration = 15s, sample-rate = 48000, channel-count = 1

I joined Video 1 and Video 2 --> Video 3 (duration 30s) [Success] But: 00s - 15s : The sound worked normally 16s - 30s: The sound didn't good. Like Minion is talking.

Sorry about my explanation. It's difficult to explain. If you have any idea or solution for this issue, please help me. Thank you very much.

sentox commented 6 years ago

I can only tell you that It's because these two Video's audio track has different sample-rate,it will cause the problem .you have to resample it to same sample-rate, m4m had a library calls libippresample.so, but I can't find it, you should try another way, If you success ,please tell me.