Fix the timestamps of PGS subs in some rare cases.
This commit is contained in:
1 parent
45619d646a
commit
a958753d3d
1 file changed
+19
-11
@@ -298,6 +298,9 @@
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableString *text = [NSMutableString string];
|
||||||
|
BOOL forced = NO;
|
||||||
|
|
||||||
for (unsigned i = 0; i < subtitle.num_rects; i++) {
|
for (unsigned i = 0; i < subtitle.num_rects; i++) {
|
||||||
AVSubtitleRect *rect = subtitle.rects[i];
|
AVSubtitleRect *rect = subtitle.rects[i];
|
||||||
if (rect->w == 0 || rect->h == 0) {
|
if (rect->w == 0 || rect->h == 0) {
|
||||||
@@ -326,8 +329,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL forced = NO;
|
|
||||||
|
|
||||||
if (rect->flags & AV_SUBTITLE_FLAG_FORCED) {
|
if (rect->flags & AV_SUBTITLE_FLAG_FORCED) {
|
||||||
forced = YES;
|
forced = YES;
|
||||||
}
|
}
|
||||||
@@ -351,18 +352,14 @@
|
|||||||
|
|
||||||
CGImageRef filteredCGImage = [self createfilteredCGImage:cgImage];
|
CGImageRef filteredCGImage = [self createfilteredCGImage:cgImage];
|
||||||
|
|
||||||
NSString *text = nil;
|
NSString *ocrText;
|
||||||
MP42SampleBuffer *subSample = nil;
|
if ((ocrText = [_ocr performOCROnCGImage:filteredCGImage])) {
|
||||||
if ((text = [_ocr performOCROnCGImage:filteredCGImage])) {
|
if (text.length) {
|
||||||
subSample = copySubtitleSample(sampleBuffer->trackId, text, sampleBuffer->duration, forced, NO, NO, CGSizeMake(0,0), 0);
|
[text appendString:@"\n"];
|
||||||
}
|
}
|
||||||
else {
|
[text appendString:ocrText];
|
||||||
subSample = copyEmptySubtitleSample(sampleBuffer->trackId, sampleBuffer->duration, forced);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[_outputSamplesBuffer enqueue:subSample];
|
|
||||||
[subSample release];
|
|
||||||
|
|
||||||
CGImageRelease(cgImage);
|
CGImageRelease(cgImage);
|
||||||
CGDataProviderRelease(provider);
|
CGDataProviderRelease(provider);
|
||||||
CFRelease(imgData);
|
CFRelease(imgData);
|
||||||
@@ -371,6 +368,17 @@
|
|||||||
free(imageData);
|
free(imageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MP42SampleBuffer *subSample = nil;
|
||||||
|
if (text.length) {
|
||||||
|
subSample = copySubtitleSample(sampleBuffer->trackId, text, sampleBuffer->duration, forced, NO, NO, CGSizeMake(0,0), 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
subSample = copyEmptySubtitleSample(sampleBuffer->trackId, sampleBuffer->duration, forced);
|
||||||
|
}
|
||||||
|
|
||||||
|
[_outputSamplesBuffer enqueue:subSample];
|
||||||
|
[subSample release];
|
||||||
|
|
||||||
avsubtitle_free(&subtitle);
|
avsubtitle_free(&subtitle);
|
||||||
av_packet_unref(&pkt);
|
av_packet_unref(&pkt);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user