How to know when MediaRecorder has finished writing data to file

前端 未结 6 965
迷失自我
迷失自我 2021-02-05 08:01

We\'re using MediaRecorder to record video to a file on the external storage using setOutputFile() before doing the actual recording.

Everything works fine, but the main

6条回答
  •  被撕碎了的回忆
    2021-02-05 08:36

    We solved similar problem with the following algo:

    while (file not complete)
        sleep for 1 sec
        read the fourth byte of the file
        if it is not 0 (contains 'f' of the 'ftyp' header) then
            file is complete, break
    

    The key point is that MediaRecorder writes the ftyp box at the very last moment. If it is in place, then the file is complete.

提交回复
热议问题