Baseflow / XamarinMediaManager

Cross platform Xamarin plugin to play and control Audio and Video
https://baseflow.com
MIT License
769 stars 305 forks source link

iOS Recorded Video playback is mute when > 10 Seconds #384

Closed WilliamABradley closed 6 years ago

WilliamABradley commented 6 years ago
### Steps to reproduce :scroll: Repro repo: https://github.com/WilliamABradley/VideoCaptureDemo 1. Run the App on an iOS Device (Problem observed on iPad Pro (2nd Gen w/ 11.3), enable Permissions for Microphone and Camera. 2. Record Video for 11 seconds or longer (Down to 4 on the Countdown) 3. Play the Video back on the Playback page, there is no sound. ### Expected behavior :thinking: Any video length should playback with audio. ### Actual behavior :bug: Videos longer than 11 seconds play with no audio. Audio is contained in the file, as when uploaded to Dropbox, it has audio. I have tried delaying playback of the player, thinking that maybe a file handle was still open, saving the audio data, but this does not work, and playing the video cold (App restart, the audio is still mute). ### Configuration :wrench: **Version:** 2.x **Platform:** - [x] :iphone: iOS - [ ] :robot: Android - [ ] :checkered_flag: WPF - [ ] :earth_americas: UWP - [ ] :apple: MacOS - [ ] :tv: tvOS - [x] :monkey: Xamarin.Forms
WilliamABradley commented 6 years ago

ping @martijn00

WilliamABradley commented 6 years ago

I found the issue, it turns out AVPlayer can't play a video from AVCaptureSession that has a .MP4 extension that is longer than 10 seconds by default. This is due to fact that AVCaptureMovieFileOutput creates a MovieFragment every 10 seconds. MP4 doesn't support fragmentation, so for some reason all iOS devices can't play the video, but everything else can.

The fix:

var movieOutput = new AVCaptureMovieFileOutput
{
    MovieFragmentInterval = CoreMedia.CMTime.Invalid
};

Turns out this library wasn't the issue, but the video created without this change that is > 10 seconds, <= 15 seconds isn't playable (Even in the Photos app!)

Ludotrico commented 4 years ago

@WilliamABradley I am having a similar issue with Swifty Cam, a top Swift media capture library. Do you know of any solution in Swift?

sumitkapoorshineweb commented 3 years ago

I found the issue, it turns out AVPlayer can't play a video from AVCaptureSession that has a .MP4 extension that is longer than 10 seconds by default. This is due to fact that AVCaptureMovieFileOutput creates a MovieFragment every 10 seconds. MP4 doesn't support fragmentation, so for some reason all iOS devices can't play the video, but everything else can.

The fix:

var movieOutput = new AVCaptureMovieFileOutput
{
    MovieFragmentInterval = CoreMedia.CMTime.Invalid
};

Turns out this library wasn't the issue, but the video created without this change that is > 10 seconds, <= 15 s

I found the issue, it turns out AVPlayer can't play a video from AVCaptureSession that has a .MP4 extension that is longer than 10 seconds by default. This is due to fact that AVCaptureMovieFileOutput creates a MovieFragment every 10 seconds. MP4 doesn't support fragmentation, so for some reason all iOS devices can't play the video, but everything else can.

The fix:

var movieOutput = new AVCaptureMovieFileOutput
{
    MovieFragmentInterval = CoreMedia.CMTime.Invalid
};

Turns out this library wasn't the issue, but the video created without this change that is > 10 seconds, <= 15 seconds isn't playable (Even in the Photos app!)

this is accepted answers, Recently I got same issue and did changes in this file 'SwiftyCamViewController.swift' inside 'configureVideoOutput' method

    let movieFileOutput = AVCaptureMovieFileOutput()
    movieFileOutput.movieFragmentInterval = CoreMedia.CMTime.invalid ///Added to fix not recording sound for more than 10 second video when recording with camera

Hopefully this helps someone to fix this issue....