2

In my app I record two 30sec video and upload to server,I done it using MediaRecorder . I want to know is there any way to find the video file size before recording start, or how to detect low memory to record video?

Shijil
  • 2,056
  • 13
  • 32

1 Answers1

2

You won't be able to find the video size before you start recording it. You could probably really, REALLY, REALLY roughly estimate the upper bound of the video file size. You could do this with the knowledge of:

  • the resolution of the video to be recorded
  • frame per second of your video recording
  • duration of the video
  • used video encoder
  • and the estimation of "typical" parameters of a video file encoded with the encoder

As for the last one, there are some tools that let you obtain such information (for example like this).

Why is it rough calculation? First of all because the data you need to get (about the videos encoded with the specific encoder) will always be just estimated. Encoder will work differently on different recording, and the sizes of video files can vary depending on many factors (including colors of the recording, dynamism of the recording - is this video still or very dynamic, or even audio). Also you need to remember that (according to this) Android let's only set the maximum video frame rate (that's why you can only estimate the upper bound of the maximum video file size).

As for the memory part of the question: take a look at this.

Community
  • 1
  • 1
Bartek Lipinski
  • 27,311
  • 8
  • 79
  • 116