04-04 16:55:57.099 28015-28195/com.rockylearnstorock.testcamera D/mediahelper:{csd-1=java.nio.bytearraybuffer[position=0,limit=8,capacity=8], MIME=VIDEO/AVC, frame-rate=30, rotation-degrees=270, height=144, width=176, max-input-size=5755, durationus=21107833, csd-0= JAVA.NIO.BYTEARRAYBUFFER[POSITION=0,LIMIT=20,CAPACITY=20]}
04-04 16:55:57.106 28015-28195/com.rockylearnstorock.testcamera D/mediahelper:{mime=audio/mpeg, durationus=256835918, encoder-delay=576, channel-count=2, encoder-padding=1681, sample-rate= 44100, bit-rate=128000}
04-04 16:55:57.106 28015-28195/com.rockylearnstorock.testcamera E/mpeg4writer:unsupported mime ' audio/mpeg '
04-04 16:55:57.107 28015-28195/com.rockylearnstorock.testcamera W/system.err:java.lang.IllegalStateException:Failed to add the track to the Muxer
04-04 16:55:57.111 28015-28195/com.rockylearnstorock.testcamera W/system.err:at Android.media.MediaMuxer.nativeAddTrack (Native Method)
04-04 16:55:57.111 28015-28195/com.rockylearnstorock.testcamera w/system.err:at android.media.MediaMuxer.addTrack ( mediamuxer.java:294)
04-04 16:55:57.112 28015-28195/com.rockylearnstorock.testcamera W/system.err:at Com.rockylearnstorock.testcamera.MediaHelper.combineAudioVideo (mediahelper.java:181)
04-04 16:55:57.112 28015-28195/com.rockylearnstorock.testcamera W/system.err:at Com.rockylearnstorock.testcamera.mainactivity$2.run (mainactivity.java:399)
04-04 16:55:57.112 28015-28195/com.rockylearnstorock.testcamera w/system.err:at java.lang.Thread.run (Thread.java : 818)
Google "Unsupported mime ' audio/mpeg ', find stackoverflow:impossible to mix audio file and video file using Mediamu Xer?
There's an explanation inside.
Mediamuxer does not transcode. If you write a MPEG4 file, it'll expect the video file to being MPEG4/AAC and the audio file to is an AAC file (M4A) a s well. Once you feeds it with an M4A, muxing'll succeed.
Try replacing MP3 with m4a files, crafting, negtive.
This post also has a person who has sent a GitHub example, trying to synthesize the video M4A's voice is not added at all. Negtive.
Google "java.lang.IllegalStateException:Failed to add the track to the Muxer", return the results, are "java.lang.IllegalState exception:failed to stop the track to the Muxer ". This is obviously not my question.
And the wrong line of reading.
int audiotrackindex = Muxer.addtrack (Audioformat); mediahelper.java:181 Error Line
The display is adding Audioformat to the muxer times wrong.
For the mediaformat of MP4 and MP3, the printed results are shown in the yellow section above:
Mp4:{csd-1=java.nio.bytearraybuffer[position=0,limit=8,capacity=8], MIME=VIDEO/AVC, frame-rate=30, rotation-degrees=270, height=144, width=176, max-input-size=5755, durationus=21107833, csd-0= JAVA.NIO.BYTEARRAYBUFFER[POSITION=0,LIMIT=20,CAPACITY=20]}
Mp3:{mime=audio/mpeg, durationus=256835918, encoder-delay=576, channel-count=2, encoder-padding=1681, sample-rate= 44100, bit-rate=128000}
One of the two codes is AVC and the other is MPEG.
According to my understanding, different coding may cause the error in this method. Because, "Unsupported mime ' audio/mpeg '".
Mediaextractor Audioextractor =NewMediaextractor (); Try{Audioextractor.setdatasource ("/storage/emulated/0/dcim/testcamera/kisstherain.mp3"); } Catch(IOException e) {e.printstacktrace (); LOG.D ("Mediahelper", "MP3 file can not is found"); return; } Mediaformat Audioformat=NULL; for(inti = 0; I < Audioextractor.gettrackcount (); i++) {Audioformat=Audioextractor.gettrackformat (i); String MIME=audioformat.getstring (mediaformat.key_mime); if(Mime.startswith ("audio/")) { Break; } } if(Audioformat = =NULL) {LOG.D ("Mediahelper", "Audioformat is null"); return; }Else{LOG.D ("Mediahelper", audioformat.tostring ()); } int audiotrackindex = Muxer.addtrack (audioformat);//mediahelper.java:181 Error Line
Android Video Processing summary