0

I have 2 sample videos (v1 50MB and v2 150MB). They are the same video where v1 is downscaled from v2.

v1 resides in our firebase bucket while v2 is a sample video available online. However, if I try to stream v1 in react-native or even in the web browser, the streaming is orders of magnitude(takes a min to start playing) rather than v2 (starts in a few seconds).

What could be the problem? It appears the simple urls are streaming and buffering perfectly in react-native-video while firebase urls 'seem' to be downloaded first and then played.

EFreak
  • 3,119
  • 3
  • 27
  • 31

2 Answers2

4

The problem is the placement of the moov box (a container for all metadata) in the MP4 files. In the case of v1 it's placed at the end and the entire file needs to be downloaded before the playback can start. In the case of v2 it's placed in the beginning so playback can start immediately. You need to optimize v1, look-up MP4 fast-start.

aergistal
  • 29,947
  • 5
  • 70
  • 92
  • This is indeed the problem. When I uploaded v2 in the same bucket, the file would stream normally => clearly implying that the problem is with the file. – EFreak Nov 08 '19 at 06:50
  • @EFreak look at the encoding options when downscaling, it must have a way to enable it. – aergistal Nov 08 '19 at 08:11
  • I'm doing this on an Android device, yet to find a resolution using MediaCodec. However, my follow up is that even after moving the moov box, the video still loads slower than v2 (10s vs 2s). Is there any other trick in streaming here? – EFreak Nov 08 '19 at 08:15
  • @EFreak with both on the same server? If one is on a different server there might be differences in routes / latency. – aergistal Nov 08 '19 at 08:21
  • yes. They are in the same bucket. And the loading difference is consistent. – EFreak Nov 08 '19 at 08:22
  • Found the problem: Keyframing was incorrect. It was set to 10sec while 2sec is the recommended value. – EFreak Nov 11 '19 at 14:27
  • Here is a decent guideline: https://www.wowza.com/blog/optimizing-video-encoding-settings-for-your-use-case – EFreak Nov 11 '19 at 14:33
0

I was searching for this since a long time. I had a video which was first completely getting 'downloaded' and then it used to start playing.

It seems like the metadata of video is at the end of video.

Then I downloaded "MP4 fast-start" and it somehow optimises the videos. Immediately the time before video starts playing reduced to 2-4 seconds from 10-12 seconds.

Chinmay Atrawalkar
  • 942
  • 1
  • 8
  • 6