How to provide both audio data and video data to MediaMux

情到浓时终转凉″ 提交于 2019-11-30 14:12:34
lighty

I have had some success passing synced audio and video to MediaMuxer. I calculated the number of audio samples that should play for each frame of video: based on the audio sample rate and the video frame rate. I then had a loop that wrote one video frame and one block of audio in each iteration. Use the presentation time to ensure they will be synced on playback. Use the track index from addTrack in calls to writeSampleData to allow writing video and audio to two separate tracks.

In aggregate to answer @robin-royal, in order to encode both video and audio y should call twice the Addtrack method of MediaMuxer, One track index (int) to each one. so then when you call WriteSampleData in the MediaMuxer, the first parameter specifies the track index, e. g. if audioTrackIndex=2 and videoTrackIndex=1, if you call WriteSampleData with the first parameter equals 1, you would be writing video. (Sorry I have no privileges to answer him in the comment) thanks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!