Open claygarrett opened 9 years ago
I'm experiencing the same problem with one specific video: http://s000.tinyupload.com/download.php?file_id=82374120368985813538&t=8237412036898581353837485
I have a small video editor app (crop, trim, scale & pan a video). The crash happens if I try to crop the video (to be landscape) and trim it from 00:00 - 00:05.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVAssetWriter endSessionAtSourceTime:] invalid parameter not satisfying: ((Boolean)(((endTime).flags & (kCMTimeFlags_Valid | kCMTimeFlags_ImpliedValueFlagsMask)) == kCMTimeFlags_Valid))'
*** First throw call stack:
(
0 CoreFoundation 0x000000010cc99c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c92fbb7 objc_exception_throw + 45
2 AVFoundation 0x000000010c660aed -[AVAssetWriter cancelWriting] + 0
3 Clashem 0x00000001083fc4d2 -[SDAVAssetExportSession finish] + 466
4 Clashem 0x00000001083fac1a __68-[SDAVAssetExportSession exportAsynchronouslyWithCompletionHandler:]_block_invoke + 362
5 AVFoundation 0x000000010c673d2e -[AVAssetWriterInputMediaDataRequester requestMediaDataIfNecessary] + 88
6 libdispatch.dylib 0x000000010dd18186 _dispatch_call_block_and_release + 12
7 libdispatch.dylib 0x000000010dd37614 _dispatch_client_callout + 8
8 libdispatch.dylib 0x000000010dd1e6a7 _dispatch_queue_drain + 2176
9 libdispatch.dylib 0x000000010dd1dcc0 _dispatch_queue_invoke + 235
10 libdispatch.dylib 0x000000010dd213b9 _dispatch_root_queue_drain + 1359
11 libdispatch.dylib 0x000000010dd22b17 _dispatch_worker_thread3 + 111
12 libsystem_pthread.dylib 0x000000010e0a4637 _pthread_wqthread + 729
13 libsystem_pthread.dylib 0x000000010e0a240d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
From Crashalytics:
I also see this all the time. According to the docs it's not necessary to call endSessionAtSourceTime:
. Has anyone tried just taking it out?
You do not need to call this method; if you call finishWriting without calling this method, the session's effective end time will be the latest end timestamp of the session's samples (that is, no samples will be edited out at the end).
Thanks!
Hey @hannesjung thanks for posting the cat video, I was able to recreate the bug with it.
I know it was a while ago, but do you remember how it was created? Was it the stock camera app? What model iPhone? Thanks.
@bcattle thanks for that suggestion to comment out endSessionAtSourceTime! Would like to confirm that this has helped resolve the issue for us.
@bcattle sorry I don't have any info about the video, got that from one of my users. I think it was sent via WhatsApp or another app (and probably transcoded by it).
Any one know what caused it? Commenting it out I get some different errors, but unsure if what I want is possible with this setup. Videos A, B, C, images D and E.
End result is a video with A, B, C top to tail. Image D would overlap from 1sec for duration of 5sec, image E would overlap from 7sec for 5sec. Total duration of the entire AVMutableVideoComposition is > 12sec so I don't think its a bug hitting the end.
When I comment it out I get this,
[21:58:21.693] FigFileForkRead signalled err=22 (errno) (pread failed) at /SourceCache/CoreMedia_frameworks/CoreMedia-1562.238/Sources/Platform/Darwin/DarwinFile.c line 507
[21:58:21.693] <<<< FigFile >>>> FigFileForkRead: fork 0x60000001ccb0 fd 22 9 bytes @ -9 buf 0x10e5f0000 FAILED errno 22 (Invalid argument)
[21:58:21.693] FigFileByteStreamRead signalled err=22 (err) (Unexpected read error) at /SourceCache/CoreMedia_frameworks/CoreMedia-1562.238/Sources/DataIO/FigByteStreams/FigByteStream_File.c line 402
(Exception may bind differently as I made SDAVAssetExportSession a dynamic library and the bound it in a Xamarin C# Binding library for use in a Xamarin.Mac OSX app)
I don't know why, but 2 modifications below goes well without commenting out endSessionAtSourceTime.
exportAsynchronouslyWithCompletionHandler:
__block BOOL videoCompleted = NO;
__block BOOL audioCompleted = NO;
__weak typeof(self) wself = self;
videoCompleted = NO; // added
audioCompleted = NO; // added
and encodeReadySamplesFromOutput:
while (input.isReadyForMoreMediaData)
{
CMSampleBufferRef sampleBuffer = [output copyNextSampleBuffer];
if (sampleBuffer)
{
// ...
}
else
{
// added from:
switch (self.reader.status ){
case AVAssetReaderStatusReading:
break;
default:
break;
}
// added end.
[input markAsFinished];
return NO;
}
}
We're getting a bunch of these in our app as well. Seems to only effect iPhone5, iPhoen5c, and iPhone4s. Is there a verified fix for this ?
there is also a crash on [AVAssetWriter startSessionAtSourceTime:] invalid parameter not satisfying: ((Boolean)(((startTime).flags & (kCMTimeFlags_Valid
About 1 in 100 of our users' video exports crashes in
at:
with the exception:
If my logic is correct, it appears that to cause this crash, lastSamplePresentationTime.flags would have to contain one of the following:
(Flag reference from: CMTime Reference)
Any idea if this appears to be a bug in implementation of the library or some sort of timing discrepancy in the composition?
BTW -- Awesome library and a real time saver for us!
Thanks! Clay