ffmpeg.c: count subtitles in total size.
This avoids the "Output file is empty" warning with subtitles-only files.
This commit is contained in:
		
							parent
							
								
									c49e960a60
								
							
						
					
					
						commit
						8c3514647e
					
				
							
								
								
									
										11
									
								
								ffmpeg.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								ffmpeg.c
									
									
									
									
									
								
							@ -163,6 +163,7 @@ static int run_as_daemon  = 0;
 | 
				
			|||||||
static volatile int received_nb_signals = 0;
 | 
					static volatile int received_nb_signals = 0;
 | 
				
			||||||
static int64_t video_size = 0;
 | 
					static int64_t video_size = 0;
 | 
				
			||||||
static int64_t audio_size = 0;
 | 
					static int64_t audio_size = 0;
 | 
				
			||||||
 | 
					static int64_t subtitle_size = 0;
 | 
				
			||||||
static int64_t extra_size = 0;
 | 
					static int64_t extra_size = 0;
 | 
				
			||||||
static int nb_frames_dup = 0;
 | 
					static int nb_frames_dup = 0;
 | 
				
			||||||
static int nb_frames_drop = 0;
 | 
					static int nb_frames_drop = 0;
 | 
				
			||||||
@ -1688,6 +1689,7 @@ static void do_subtitle_out(AVFormatContext *s,
 | 
				
			|||||||
                pkt.pts += 90 * sub->end_display_time;
 | 
					                pkt.pts += 90 * sub->end_display_time;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        write_frame(s, &pkt, ost);
 | 
					        write_frame(s, &pkt, ost);
 | 
				
			||||||
 | 
					        subtitle_size += pkt.size;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2123,15 +2125,16 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
 | 
				
			|||||||
    fflush(stderr);
 | 
					    fflush(stderr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (is_last_report) {
 | 
					    if (is_last_report) {
 | 
				
			||||||
        int64_t raw= audio_size + video_size + extra_size;
 | 
					        int64_t raw= audio_size + video_size + subtitle_size + extra_size;
 | 
				
			||||||
        av_log(NULL, AV_LOG_INFO, "\n");
 | 
					        av_log(NULL, AV_LOG_INFO, "\n");
 | 
				
			||||||
        av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
 | 
					        av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB subtitle:%1.0f global headers:%1.0fkB muxing overhead %f%%\n",
 | 
				
			||||||
               video_size / 1024.0,
 | 
					               video_size / 1024.0,
 | 
				
			||||||
               audio_size / 1024.0,
 | 
					               audio_size / 1024.0,
 | 
				
			||||||
 | 
					               subtitle_size / 1024.0,
 | 
				
			||||||
               extra_size / 1024.0,
 | 
					               extra_size / 1024.0,
 | 
				
			||||||
               100.0 * (total_size - raw) / raw
 | 
					               100.0 * (total_size - raw) / raw
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        if(video_size + audio_size + extra_size == 0){
 | 
					        if(video_size + audio_size + subtitle_size + extra_size == 0){
 | 
				
			||||||
            av_log(NULL, AV_LOG_WARNING, "Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)\n");
 | 
					            av_log(NULL, AV_LOG_WARNING, "Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)\n");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -2253,6 +2256,8 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
 | 
				
			|||||||
    else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
 | 
					    else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
 | 
				
			||||||
        video_size += pkt->size;
 | 
					        video_size += pkt->size;
 | 
				
			||||||
        ost->sync_opts++;
 | 
					        ost->sync_opts++;
 | 
				
			||||||
 | 
					    } else if (ost->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
 | 
				
			||||||
 | 
					        subtitle_size += pkt->size;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pkt->pts != AV_NOPTS_VALUE)
 | 
					    if (pkt->pts != AV_NOPTS_VALUE)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user