Question

When recording a movie with AVFoundation the recording is automatically stopped at around 34 minutes with error code -11813: AVErrorMaximumNumberOfSamplesForFileFormatReached

After doing some research on the QuickTime File Format Specs it appears that the Atom header does not contain an extended size field. The specification tells me:

If the size field of an atom is set to 1, the type field is followed by a 64-bit extended size field, which contains the actual size of the atom as a 64-bit unsigned integer. This is used when the size of a media data atom exceeds 2^32 bytes.

Apparently if the extended size field is not present - which is the case when the size field contains the actual size of the atom I cannot write beyond 2^32 bytes - as documented here:

When the size field contains the actual size of the atom, the extended size field is not present. This means that when a QuickTime atom is modified by adding data, and its size crosses the 2^32 byte limit, there is no extended size field in which to record the new atom size. Consequently, it is not always possible to enlarge an atom beyond 2^32 bytes without copying its contents to a new atom.

I am using AVCaptureMovieFileOutput to record from my AVCaptureSession which has a video and an audio AVCaptureDeviceInput

My question: How can I manually set the size field to 1? Or is using AVCaptureMovieFileOutput the wrong approach - and should I go with an AVAssetWriter approach? I am recording video and audio from a live video grabber and audio input.

The problem is reproducable with the sample project by Apple itself AVRecorder. Changing the sessionPresets does not solve the problem.

I did not have this limitation with my QTKit application. QuickTime Player X itself can also record beyond this 34 minute boundary.

Is this a known issue - or am I missing out on something?

Was it helpful?

Solution

The issue is solved. In the end it was a driver update issue.

General details:

I am using Epiphan DVI2USB Solo and DVI2USB 3.0 frame grabbers on a Mac environment.
Drivers with the version 3.27.7 and below would not work.
The issue is adressed with a new driver update 3.27.8 by Epiphan
In the changelog it explicitly states the issue I had.

Now it works

Technical background:

I posted my problem to the QuickTime API Mailing List. Apple and Epiphan replied. Apple explained it very precisely:

This isn't a file size problem. It's a duration timescale problem. The QT movie file duration field is only 32-bit and is expressed in the timescale of the movie. On Mac OS X, AVCaptureMovieFileOutput uses the timescale of your video capture source as the movie timescale to preserve precision (for editing). So if your video device is using a timescale of 1000000, then:

2147483647 / 1000000 = 2147 seconds, or 35 minutes.

Also one cannot influence the timescale with an AVCaptureMovieFileOutput Setup. One needs to work with the CMSampleBufferRef and an AVAssetWriter setup: Apple says:

There's currently no way to influence AVCaptureMovieFileOutput's timescale choice. It uses the video device's timescale. One workaround would be to use AVCaptureVideoDataOutput/AVCaptureAudioDataOutput to get buffers sent to your delegate callback, then write the buffers with AVAssetWriter, which uses a movie time scale of 600. It also gives you the opportunity to specify the media timescale, which you could set to something lower so you can record longer movies (see AVAssetWriterInput.h).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top