Right now the .mp4 example writes directly to the output filename and only writes the moov information on success. So if there's an error (eg in https://github.com/scottlamb/retina/issues/30#issuecomment-907557410) you end up with a .mp4 file which doesn't play correctly. I don't want to complicate it too much (given that it's just an example rather than intended to be a fully productionized tool) but I think it'd be simple enough to do the following:
append .partial to the filename and only rename that part away after writing the index, so it's obvious when the file is half-written
on error, finish writing the indexes for the frames we already have, if any
if we don't have any frames when exiting, just delete the .partial file
Right now the
.mp4
example writes directly to the output filename and only writes themoov
information on success. So if there's an error (eg in https://github.com/scottlamb/retina/issues/30#issuecomment-907557410) you end up with a.mp4
file which doesn't play correctly. I don't want to complicate it too much (given that it's just an example rather than intended to be a fully productionized tool) but I think it'd be simple enough to do the following:.partial
to the filename and only rename that part away after writing the index, so it's obvious when the file is half-written.partial
file