diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-03-24 16:40:35 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-03-24 16:40:35 +0100 |
commit | 1046cd60d4b19d6376dd18164959c3ea30477855 (patch) | |
tree | c1f2921d1f0e50bbaeb0a0868e8a1ec88c80dddb | |
parent | afa442c198fcbfe587887a4318d61e19539afc2d (diff) | |
parent | 4754345027eb85cfa51aeb88beec68d7b036c11e (diff) | |
download | ffmpeg-1046cd60d4b19d6376dd18164959c3ea30477855.tar.gz |
Merge commit '4754345027eb85cfa51aeb88beec68d7b036c11e'
* commit '4754345027eb85cfa51aeb88beec68d7b036c11e':
avconv: print verbose per-stream transcoding statistics
Conflicts:
ffmpeg.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | ffmpeg.c | 91 | ||||
-rw-r--r-- | ffmpeg.h | 17 |
2 files changed, 104 insertions, 4 deletions
@@ -646,6 +646,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) ost->last_mux_dts = pkt->dts; ost->data_size += pkt->size; + ost->packets_written++; pkt->stream_index = ost->index; @@ -708,6 +709,8 @@ static void do_audio_out(AVFormatContext *s, OutputStream *ost, if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0) frame->pts = ost->sync_opts; ost->sync_opts = frame->pts + frame->nb_samples; + ost->samples_encoded += frame->nb_samples; + ost->frames_encoded++; av_assert0(pkt.size || !pkt.data); update_benchmark(NULL); @@ -717,6 +720,7 @@ static void do_audio_out(AVFormatContext *s, OutputStream *ost, av_ts2str(frame->pts), av_ts2timestr(frame->pts, &enc->time_base), enc->time_base.num, enc->time_base.den); } + if (avcodec_encode_audio2(enc, &pkt, frame, &got_packet) < 0) { av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_encode_audio2)\n"); exit_program(1); @@ -792,6 +796,9 @@ static void do_subtitle_out(AVFormatContext *s, sub->start_display_time = 0; if (i == 1) sub->num_rects = 0; + + ost->frames_encoded++; + subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out, subtitle_out_max_size, sub); if (subtitle_out_size < 0) { @@ -982,6 +989,7 @@ static void do_video_out(AVFormatContext *s, ost->forced_keyframes_expr_const_values[FKF_N] += 1; } + if (forced_keyframe) { in_picture->pict_type = AV_PICTURE_TYPE_I; av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time); @@ -995,6 +1003,8 @@ static void do_video_out(AVFormatContext *s, enc->time_base.num, enc->time_base.den); } + ost->frames_encoded++; + ret = avcodec_encode_video2(enc, &pkt, in_picture, &got_packet); update_benchmark("encode_video %d.%d", ost->file_index, ost->index); if (ret < 0) { @@ -1184,7 +1194,7 @@ static void print_final_stats(int64_t total_size) uint64_t subtitle_size = 0; uint64_t data_size = 0; float percent = -1.0; - int i; + int i, j; for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; @@ -1213,6 +1223,75 @@ static void print_final_stats(int64_t total_size) else av_log(NULL, AV_LOG_INFO, "unknown"); av_log(NULL, AV_LOG_INFO, "\n"); + + /* print verbose per-stream stats */ + for (i = 0; i < nb_input_files; i++) { + InputFile *f = input_files[i]; + uint64_t total_packets = 0, total_size = 0; + + av_log(NULL, AV_LOG_VERBOSE, "Input file #%d (%s):\n", + i, f->ctx->filename); + + for (j = 0; j < f->nb_streams; j++) { + InputStream *ist = input_streams[f->ist_index + j]; + enum AVMediaType type = ist->st->codec->codec_type; + + total_size += ist->data_size; + total_packets += ist->nb_packets; + + av_log(NULL, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", + i, j, media_type_string(type)); + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", + ist->nb_packets, ist->data_size); + + if (ist->decoding_needed) { + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames decoded", + ist->frames_decoded); + if (type == AVMEDIA_TYPE_AUDIO) + av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded); + av_log(NULL, AV_LOG_VERBOSE, "; "); + } + + av_log(NULL, AV_LOG_VERBOSE, "\n"); + } + + av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", + total_packets, total_size); + } + + for (i = 0; i < nb_output_files; i++) { + OutputFile *of = output_files[i]; + uint64_t total_packets = 0, total_size = 0; + + av_log(NULL, AV_LOG_VERBOSE, "Output file #%d (%s):\n", + i, of->ctx->filename); + + for (j = 0; j < of->ctx->nb_streams; j++) { + OutputStream *ost = output_streams[of->ost_index + j]; + enum AVMediaType type = ost->st->codec->codec_type; + + total_size += ost->data_size; + total_packets += ost->packets_written; + + av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", + i, j, media_type_string(type)); + if (ost->encoding_needed) { + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", + ost->frames_encoded); + if (type == AVMEDIA_TYPE_AUDIO) + av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ost->samples_encoded); + av_log(NULL, AV_LOG_VERBOSE, "; "); + } + + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", + ost->packets_written, ost->data_size); + + av_log(NULL, AV_LOG_VERBOSE, "\n"); + } + + av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", + total_packets, total_size); + } if(video_size + data_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"); } @@ -1641,6 +1720,9 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) return ret; } + ist->samples_decoded += decoded_frame->nb_samples; + ist->frames_decoded++; + #if 1 /* increment next_dts to use for the case where the input stream does not have timestamps or there are multiple frames in the packet */ @@ -1781,6 +1863,8 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) if(ist->top_field_first>=0) decoded_frame->top_field_first = ist->top_field_first; + ist->frames_decoded++; + if (ist->hwaccel_retrieve_data && decoded_frame->format == ist->hwaccel_pix_fmt) { err = ist->hwaccel_retrieve_data(ist->st->codec, decoded_frame); if (err < 0) @@ -1902,6 +1986,8 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) if (!subtitle.num_rects) goto out; + ist->frames_decoded++; + for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; @@ -3177,7 +3263,10 @@ static int process_input(int file_index) } ist = input_streams[ifile->ist_index + pkt.stream_index]; + + ist->data_size += pkt.size; ist->nb_packets++; + if (ist->discard) goto discard_packet; @@ -262,9 +262,6 @@ typedef struct InputStream { int top_field_first; int guess_layout_max; - /* number of packets successfully read for this stream */ - uint64_t nb_packets; - int resample_height; int resample_width; int resample_pix_fmt; @@ -309,6 +306,15 @@ typedef struct InputStream { int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame); enum AVPixelFormat hwaccel_pix_fmt; enum AVPixelFormat hwaccel_retrieved_pix_fmt; + + /* stats */ + // combined size of all the packets read + uint64_t data_size; + /* number of packets successfully read for this stream */ + uint64_t nb_packets; + // number of frames/samples retrieved from the decoder + uint64_t frames_decoded; + uint64_t samples_decoded; } InputStream; typedef struct InputFile { @@ -421,6 +427,11 @@ typedef struct OutputStream { /* stats */ // combined size of all the packets written uint64_t data_size; + // number of packets send to the muxer + uint64_t packets_written; + // number of frames/samples sent to the encoder + uint64_t frames_encoded; + uint64_t samples_encoded; } OutputStream; typedef struct OutputFile { |