You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	ffmpeg: ensure that -fix_sub_duration doesnt create subtitles with zero duration
When fix_sub_duration is used, and the duration fixing code is generating 0 duration, that is definitely zero, and not undefined or infinite (which may be the case for decoded AVSubtitles depending on the codec), so it is safe to drop it. It fixes teletext subtitle sources, when the subtitles are transmitted twice after each other for some reason. Signed-off-by: Marton Balint <cus@passwd.hu> Reviewed-by: Nicolas George <george@nsup.org>
This commit is contained in:
		
							
								
								
									
										12
									
								
								ffmpeg.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								ffmpeg.c
									
									
									
									
									
								
							| @@ -1807,19 +1807,23 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) | ||||
|     } | ||||
|  | ||||
|     if (ist->fix_sub_duration) { | ||||
|         int end = 1; | ||||
|         if (ist->prev_sub.got_output) { | ||||
|             int end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts, | ||||
|                                  1000, AV_TIME_BASE); | ||||
|             end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts, | ||||
|                              1000, AV_TIME_BASE); | ||||
|             if (end < ist->prev_sub.subtitle.end_display_time) { | ||||
|                 av_log(ist->st->codec, AV_LOG_DEBUG, | ||||
|                        "Subtitle duration reduced from %d to %d\n", | ||||
|                        ist->prev_sub.subtitle.end_display_time, end); | ||||
|                        "Subtitle duration reduced from %d to %d%s\n", | ||||
|                        ist->prev_sub.subtitle.end_display_time, end, | ||||
|                        end <= 0 ? ", dropping it" : ""); | ||||
|                 ist->prev_sub.subtitle.end_display_time = end; | ||||
|             } | ||||
|         } | ||||
|         FFSWAP(int,        *got_output, ist->prev_sub.got_output); | ||||
|         FFSWAP(int,        ret,         ist->prev_sub.ret); | ||||
|         FFSWAP(AVSubtitle, subtitle,    ist->prev_sub.subtitle); | ||||
|         if (end <= 0) | ||||
|             goto out; | ||||
|     } | ||||
|  | ||||
|     if (!*got_output) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user