Repository: flutter
Issue: [video_player] Some kind of mp4 videos are glitching when setLooping(true) 
Labels: platform-android,a: video,p: video_player,package,has reproducible steps,P2,found in release: 2.2,found in release: 2.3,team-android,triaged-android

Hey, everyone. Firstly, - I want to say thank you to all contributors to this wonderful video_player plugin, and share my investigation results during its usage.
So, what's happening? 
When anybody takes [official example](https://github.com/flutter/plugins/tree/master/packages/video_player/video_player/example) and using the video provided inside (with setLooping(true) controller option) -- the player works well, without any delays or unexpected stops.
But in my case, when I setting up my URL links or as asset, some videos starting to glitch during playback.
I've tested it on my Android Simulator and real device Redme Note9 + my colleagues did the same and found this bug too.

## Steps to Reproduce
1. Download [official example](https://github.com/flutter/plugins/tree/master/packages/video_player/video_player/example)
2. [https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4](https://github.com/flutter/plugins/blob/master/packages/video_player/video_player/example/lib/main.dart#L221) change to `https://coub-anubis-a.akamaized.net/coub_storage/coub/simple/cw_file/ecd5de8ba36/b263202372bca9c057beb/muted_mp4_med_size_1606083242_muted_med.mp4` OR `https://coub-anubis-a.akamaized.net/coub_storage/coub/simple/cw_file/7db5974242a/1467e45ea23b4048cbd87/muted_mp4_med_size_1606078793_muted_med.mp4`
3. Ensure setLooping(true)
4. Start simulator and watch when the video stops and starting to tremble

At first, I thought there was a problem in buffering video playback from the stream, but this problem remains unchanged even if the video is downloaded and run as an asset.
As I said before, not all videos work. 
There is a list of videos which work well:
1. `https://coubsecure-s.akamaihd.net/get/b173/p/coub/simple/cw_file/b737387a6bf/b354961bb7266453d9857/muted_mp4_med_size_1605460682_muted_med.mp4`
2. `https://coubsecure-s.akamaihd.net/get/b128/p/coub/simple/cw_file/77ba9bd42fd/4b679cab250a12fb3afdb/muted_mp4_med_size_1577187181_muted_med.mp4`

<details>
  <summary>Logs when was started one gliched video</summary>

```
Launching lib/main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Waiting for sdk gphone x86 arm to report its views...
Debug service listening on ws://127.0.0.1:63059/1Mi1_mCM7Ug=/ws
Syncing files to device sdk gphone x86 arm...
I/TetheringManager(21636): registerTetheringEventCallback:com.example.couber
W/.example.coube(21636): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
I/ExoPlayerImpl(21636): Init 804cea2 [ExoPlayerLib/2.12.1] [generic_x86_arm, sdk_gphone_x86_arm, Google, 30]
I/VideoCapabilities(21636): Unsupported profile 4 for video/mp4v-es
I/OMXClient(21636): IOmx service obtained
D/SurfaceUtils(21636): connecting to surface 0xe3e160b8, reason connectToSurface
I/MediaCodec(21636): [OMX.android.goldfish.h264.decoder] setting surface generation to 22155265
D/SurfaceUtils(21636): disconnecting from surface 0xe3e160b8, reason connectToSurface(reconnect)
D/SurfaceUtils(21636): connecting to surface 0xe3e160b8, reason connectToSurface(reconnect)
E/ACodec  (21636): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
I/ACodec  (21636): codec does not support config priority (err -1010)
D/SurfaceUtils(21636): disconnecting from surface 0xe3e160b8, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils(21636): connecting to surface 0xe3e160b8, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils(21636): set up nativeWindow 0xe3e160b8 for 640x360, color 0x13, rotation 0, usage 0x1002900
W/Gralloc4(21636): allocator 3.x is not supported
I/.example.coube(21636): NativeAlloc concurrent copying GC freed 28763(2191KB) AllocSpace objects, 11(380KB) LOS objects, 49% free, 5182KB/10MB, paused 2.890ms total 349.248ms
I/.example.coube(21636): Background young concurrent copying GC freed 19562(3447KB) AllocSpace objects, 30(1400KB) LOS objects, 47% free, 5431KB/10MB, paused 5.298ms total 33.333ms
I/.example.coube(21636): Background young concurrent copying GC freed 17024(2087KB) AllocSpace objects, 24(1152KB) LOS objects, 33% free, 6890KB/10MB, paused 5.460ms total 28.818ms
I/.example.coube(21636): Background young concurrent copying GC freed 8596(1468KB) AllocSpace objects, 11(508KB) LOS objects, 16% free, 8678KB/10MB, paused 1.224ms total 100.845ms
I/.example.coube(21636): Background concurrent copying GC freed 14463(1820KB) AllocSpace objects, 125(3268KB) LOS objects, 49% free, 4569KB/9139KB, paused 944us total 110.873ms
I/.example.coube(21636): Background concurrent copying GC freed 17922(2342KB) AllocSpace objects, 70(2168KB) LOS objects, 49% free, 4337KB/8674KB, paused 1.822ms total 127.595ms
I/.example.coube(21636): Background young concurrent copying GC freed 15355(2086KB) AllocSpace objects, 23(1084KB) LOS objects, 36% free, 5542KB/8674KB, paused 6.292ms total 90.624ms
I/.example.coube(21636): Background concurrent copying GC freed 16979(2290KB) AllocSpace objects, 92(2512KB) LOS objects, 49% free, 4247KB/8494KB, paused 4.051ms total 194.152ms
I/.example.coube(21636): Background concurrent copying GC freed 16708(2230KB) AllocSpace objects, 74(2248KB) LOS objects, 49% free, 4315KB/8631KB, paused 1.257ms total 156.238ms
I/.example.coube(21636): Background concurrent copying GC freed 15818(2300KB) AllocSpace objects, 64(1952KB) LOS objects, 49% free, 4534KB/9068KB, paused 4.966ms total 154.317ms
I/.example.coube(21636): Background concurrent copying GC freed 20864(2485KB) AllocSpace objects, 72(2416KB) LOS objects, 49% free, 4152KB/8304KB, paused 3.595ms total 102.114ms
I/.example.coube(21636): Background concurrent copying GC freed 16103(2033KB) AllocSpace objects, 75(2124KB) LOS objects, 49% free, 4319KB/8639KB, paused 2.351ms total 176.316ms
I/.example.coube(21636): Background concurrent copying GC freed 18777(2017KB) AllocSpace objects, 91(2636KB) LOS objects, 49% free, 4540KB/9081KB, paused 2.658ms total 117.654ms
I/.example.coube(21636): Background concurrent copying GC freed 20030(2511KB) AllocSpace objects, 83(2476KB) LOS objects, 49% free, 4554KB/9109KB, paused 3.554ms total 110.793ms
I/.example.coube(21636): Background concurrent copying GC freed 20388(2414KB) AllocSpace objects, 81(2452KB) LOS objects, 49% free, 4593KB/9186KB, paused 9.222ms total 359.094ms
W/.example.coube(21636): No such thread id for suspend: 21
I/.example.coube(21636): Background young concurrent copying GC freed 18244(2151KB) AllocSpace objects, 26(1208KB) LOS objects, 37% free, 5234KB/8439KB, paused 1.619ms total 109.604ms
I/.example.coube(21636): Background concurrent copying GC freed 15634(1851KB) AllocSpace objects, 74(2136KB) LOS objects, 49% free, 4631KB/9262KB, paused 1.043ms total 116.303ms
I/.example.coube(21636): Background concurrent copying GC freed 13954(1973KB) AllocSpace objects, 73(2068KB) LOS objects, 49% free, 4183KB/8367KB, paused 2.467ms total 127.757ms
I/.example.coube(21636): Background concurrent copying GC freed 14470(1626KB) AllocSpace objects, 91(2604KB) LOS objects, 49% free, 4573KB/9146KB, paused 5.810ms total 114.555ms
I/.example.coube(21636): Background concurrent copying GC freed 21699(2224KB) AllocSpace objects, 75(2428KB) LOS objects, 49% free, 4864KB/9729KB, paused 2.327ms total 304.622ms
I/.example.coube(21636): WaitForGcToComplete blocked Background on None for 5.623ms
I/.example.coube(21636): Background concurrent copying GC freed 17043(2208KB) AllocSpace objects, 81(2420KB) LOS objects, 49% free, 4222KB/8444KB, paused 2.373ms total 166.570ms
I/.example.coube(21636): Background concurrent copying GC freed 14103(2501KB) AllocSpace objects, 66(1976KB) LOS objects, 49% free, 4121KB/8242KB, paused 4.243ms total 123.069ms
I/.example.coube(21636): Background concurrent copying GC freed 16798(2066KB) AllocSpace objects, 58(1928KB) LOS objects, 49% free, 4389KB/8778KB, paused 1.902ms total 121.665ms
I/.example.coube(21636): Background concurrent copying GC freed 21871(2355KB) AllocSpace objects, 83(2508KB) LOS objects, 49% free, 4555KB/9110KB, paused 1.712ms total 145.591ms
I/.example.coube(21636): Background concurrent copying GC freed 13101(1879KB) AllocSpace objects, 63(1852KB) LOS objects, 49% free, 4168KB/8337KB, paused 1.120ms total 109.393ms
I/.example.coube(21636): Background concurrent copying GC freed 18479(2553KB) AllocSpace objects, 78(2328KB) LOS objects, 49% free, 4421KB/8842KB, paused 2.124ms total 100.595ms
I/.example.coube(21636): Background young concurrent copying GC freed 14809(2713KB) AllocSpace objects, 23(1084KB) LOS objects, 44% free, 4821KB/8685KB, paused 5.733ms total 61.558ms
I/.example.coube(21636): Background concurrent copying GC freed 18135(2400KB) AllocSpace objects, 66(2088KB) LOS objects, 49% free, 4395KB/8791KB, paused 1.787ms total 117.159ms
I/.example.coube(21636): Background concurrent copying GC freed 16321(2297KB) AllocSpace objects, 61(1940KB) LOS objects, 49% free, 4363KB/8726KB, paused 1.488ms total 108.321ms
I/.example.coube(21636): Background concurrent copying GC freed 17776(2357KB) AllocSpace objects, 62(2008KB) LOS objects, 49% free, 4297KB/8594KB, paused 849us total 116.888ms
I/.example.coube(21636): Background young concurrent copying GC freed 14952(2226KB) AllocSpace objects, 22(1016KB) LOS objects, 37% free, 5384KB/8594KB, paused 6.549ms total 63.428ms
I/.example.coube(21636): Background concurrent copying GC freed 17271(1968KB) AllocSpace objects, 77(2260KB) LOS objects, 49% free, 4206KB/8413KB, paused 4.071ms total 128.676ms
I/.example.coube(21636): Background concurrent copying GC freed 15955(1816KB) AllocSpace objects, 74(2328KB) LOS objects, 49% free, 4701KB/9402KB, paused 2.522ms total 153.245ms
I/.example.coube(21636): Background concurrent copying GC freed 15684(1923KB) AllocSpace objects, 58(1816KB) LOS objects, 49% free, 4162KB/8325KB, paused 1.503ms total 123.098ms
I/.example.coube(21636): Background young concurrent copying GC freed 15355(2518KB) AllocSpace objects, 23(1084KB) LOS objects, 43% free, 4798KB/8542KB, paused 6.356ms total 30.599ms
I/.example.coube(21636): Background concurrent copying GC freed 17862(3284KB) AllocSpace objects, 67(2156KB) LOS objects, 49% free, 4733KB/9467KB, paused 2.902ms total 139.243ms
I/.example.coube(21636): Background concurrent copying GC freed 15609(2218KB) AllocSpace objects, 60(1952KB) LOS objects, 49% free, 4646KB/9292KB, paused 11.387ms total 97.797ms
I/.example.coube(21636): Background concurrent copying GC freed 15918(2119KB) AllocSpace objects, 74(2136KB) LOS objects, 49% free, 4378KB/8757KB, paused 1.986ms total 111.393ms
I/.example.coube(21636): Background concurrent copying GC freed 16542(2279KB) AllocSpace objects, 72(2192KB) LOS objects, 49% free, 3887KB/7774KB, paused 7.176ms total 52.884ms
I/.example.coube(21636): Waiting for a blocking GC ProfileSaver
I/.example.coube(21636): Background concurrent copying GC freed 15762(1934KB) AllocSpace objects, 71(2124KB) LOS objects, 49% free, 4229KB/8459KB, paused 10.185ms total 160.555ms
I/.example.coube(21636): WaitForGcToComplete blocked ProfileSaver on HeapTrim for 98.906ms
I/.example.coube(21636): Background young concurrent copying GC freed 13958(2459KB) AllocSpace objects, 20(960KB) LOS objects, 41% free, 4949KB/8459KB, paused 16.926ms total 96.661ms
I/.example.coube(21636): Background concurrent copying GC freed 15553(2350KB) AllocSpace objects, 58(1816KB) LOS objects, 49% free, 4197KB/8394KB, paused 6.565ms total 55.664ms
I/.example.coube(21636): Background young concurrent copying GC freed 19243(2382KB) AllocSpace objects, 30(1400KB) LOS objects, 45% free, 4923KB/9063KB, paused 7.600ms total 54.900ms
I/.example.coube(21636): Background concurrent copying GC freed 20296(2465KB) AllocSpace objects, 75(2428KB) LOS objects, 49% free, 4447KB/8894KB, paused 3.097ms total 132.983ms
I/.example.coube(21636): Background concurrent copying GC freed 18848(2464KB) AllocSpace objects, 69(2212KB) LOS objects, 49% free, 4367KB/8735KB, paused 6.793ms total 106.121ms
I/.example.coube(21636): Background concurrent copying GC freed 19698(2392KB) AllocSpace objects, 79(2396KB) LOS objects, 49% free, 4499KB/8998KB, paused 4.562ms total 270.713ms
I/.example.coube(21636): Background concurrent copying GC freed 17789(2253KB) AllocSpace objects, 51(1836KB) LOS objects, 49% free, 4480KB/8961KB, paused 3.749ms total 122.100ms
I/.example.coube(21636): Background young concurrent copying GC freed 16112(2262KB) AllocSpace objects, 25(1140KB) LOS objects, 37% free, 5600KB/8961KB, paused 9.869ms total 50.628ms
I/.example.coube(21636): Background concurrent copying GC freed 18301(2242KB) AllocSpace objects, 88(2624KB) LOS objects, 49% free, 4701KB/9402KB, paused 1.458ms total 141.882ms
I/.example.coube(21636): Background young concurrent copying GC freed 17551(2169KB) AllocSpace objects, 27(1276KB) LOS objects, 42% free, 4985KB/8613KB, paused 5.421ms total 70.680ms
I/.example.coube(21636): Background young concurrent copying GC freed 16066(2130KB) AllocSpace objects, 26(1208KB) LOS objects, 44% free, 4808KB/8612KB, paused 6.080ms total 36.651ms
I/.example.coube(21636): Background concurrent copying GC freed 19216(2351KB) AllocSpace objects, 72(2224KB) LOS objects, 49% free, 4364KB/8728KB, paused 1.832ms total 114.839ms
I/.example.coube(21636): Background young concurrent copying GC freed 18526(2093KB) AllocSpace objects, 28(1344KB) LOS objects, 42% free, 5035KB/8728KB, paused 6.800ms total 21.996ms
I/.example.coube(21636): Background concurrent copying GC freed 16253(2407KB) AllocSpace objects, 61(1940KB) LOS objects, 49% free, 4287KB/8543KB, paused 1.740ms total 101.977ms
I/.example.coube(21636): Background young concurrent copying GC freed 16487(2478KB) AllocSpace objects, 26(1208KB) LOS objects, 45% free, 4650KB/8543KB, paused 21.189ms total 116.268ms

```

```
[✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B29 darwin-x64, locale en-GB)
    • Flutter version 1.22.4 at /Users/max/Utils/flutter
    • Framework revision 1aafb3a8b9 (11 days ago), 2020-11-13 09:59:28 -0800
    • Engine revision 2c956a31c0
    • Dart version 2.10.4


[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/max/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    • CocoaPods version 1.10.0

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.51.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (1 available)
    • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
```
</details>