Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-07-16 Thread Gyan Doshi



On 17-07-2018 02:38 AM, Wang Cao wrote:


I was thinking to output stats for each video/audio stream one line by
another. It seems this would be a huge change to users who are not
aware. Keeping the old file bitrate looks good to me. Can I extend
this to output file bitrate for each output file?


Why not keep the current stats as is, and add an option for verbose 
stats? At the next major release, we can consider making them the default.


Per-stream bitrate may be useful for those encoding HLS/DASH variants.

Regards,
Gyan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-07-16 Thread Wang Cao
> if theres a file with 5 video streams it doesnt make sense to summarize
> teh file with the bitrate of 1 stream
> Also the user has no indication of this change, the number is just different
> theres nothing informing him that it is no longer the files bitrate

I was thinking to output stats for each video/audio stream one line by
another. It seems this would be a huge change to users who are not
aware. Keeping the old file bitrate looks good to me. Can I extend
this to output file bitrate for each output file?
-- 
Wang Cao
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-07-12 Thread Michael Niedermayer
On Thu, Jul 12, 2018 at 04:31:11PM -0700, Wang Cao wrote:
> >
> > I believe users will expect that "size" shows the file size, especially
> > since this was done for more than a decade.
> 
> If this is the convention, I believe it should be kept as it was. On the
> other hand, I believe
> "bitrate" should be calculated through stream size not the file size.

if theres a file with 5 video streams it doesnt make sense to summarize
teh file with the bitrate of 1 stream

Also the user has no indication of this change, the number is just different
theres nothing informing him that it is no longer the files bitrate

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-07-12 Thread Wang Cao
>
> I believe users will expect that "size" shows the file size, especially
> since this was done for more than a decade.

If this is the convention, I believe it should be kept as it was. On the
other hand, I believe
"bitrate" should be calculated through stream size not the file size.

On Thu, Jul 12, 2018 at 2:18 PM Carl Eugen Hoyos  wrote:

> 2018-07-12 20:56 GMT+02:00, Wang Cao :
>
> > After my change:
> >
> >> frame=3 fps=0.0 q=2.0 Lsize=  51kB time=00:00:00.12
> >> bitrate=3495.7kbits/s speed=  12x
> >
> > Before my change(master branch)
> >
> >> frame=3 fps=0.0 q=2.0 Lsize=  57kB time=00:00:00.12
> >> bitrate=3884.7kbits/s speed=11.2x
> >
> > The size is different (51 vs 57) because I display the stream
> > size instead of the total file size. I think stream size
> > is more suitable in this context with "frame, fps, time".
> > For bitrate, I use the stream size to calculate it and I think
> > it's more accurate.
>
> I believe users will expect that "size" shows the file size, especially
> since this was done for more than a decade.
>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


-- 
Wang Cao
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-07-12 Thread Carl Eugen Hoyos
2018-07-12 20:56 GMT+02:00, Wang Cao :

> After my change:
>
>> frame=3 fps=0.0 q=2.0 Lsize=  51kB time=00:00:00.12
>> bitrate=3495.7kbits/s speed=  12x
>
> Before my change(master branch)
>
>> frame=3 fps=0.0 q=2.0 Lsize=  57kB time=00:00:00.12
>> bitrate=3884.7kbits/s speed=11.2x
>
> The size is different (51 vs 57) because I display the stream
> size instead of the total file size. I think stream size
> is more suitable in this context with "frame, fps, time".
> For bitrate, I use the stream size to calculate it and I think
> it's more accurate.

I believe users will expect that "size" shows the file size, especially
since this was done for more than a decade.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-07-12 Thread Wang Cao
Sorry I probably confused you a little bit. I was not suggesting removing
anything. I tried to convince you that
there is some issue with the bitrate calculation.

From your original comments:

> This changes the printed values
> ./ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -qscale 2  -vframes 3 -an
> test2.avi
> frame=3 fps=0.0 q=2.0 Lsize=  51kB time=00:00:00.12
> bitrate=3495.7kbits/s speed=  12x
> video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
> muxing overhead: 11.128063%
> vs.
> frame=3 fps=0.0 q=2.0 Lsize=  57kB time=00:00:00.12
> bitrate=3884.7kbits/s speed=11.2x
> video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
> muxing overhead: 11.128063%
> the file is the same


After my change:

> frame=3 fps=0.0 q=2.0 Lsize=  51kB time=00:00:00.12
> bitrate=3495.7kbits/s speed=  12x

Before my change(master branch)

> frame=3 fps=0.0 q=2.0 Lsize=  57kB time=00:00:00.12
> bitrate=3884.7kbits/s speed=11.2x

The size is different (51 vs 57) because I display the stream size instead
of the total file size. I think stream size
is more suitable in this context with "frame, fps, time".
For bitrate, I use the stream size to calculate it and I think it's more
accurate.


On Thu, Jul 12, 2018 at 5:01 AM Michael Niedermayer 
wrote:

> On Wed, Jul 11, 2018 at 03:47:45PM -0700, Wang Cao wrote:
> > >
> > > This changes the printed values
> > > ./ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -qscale 2  -vframes 3 -an
> > > test2.avi
> > > frame=3 fps=0.0 q=2.0 Lsize=  51kB time=00:00:00.12
> > > bitrate=3495.7kbits/s speed=  12x
> > > video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
> > > muxing overhead: 11.128063%
> > > vs.
> > > frame=3 fps=0.0 q=2.0 Lsize=  57kB time=00:00:00.12
> > > bitrate=3884.7kbits/s speed=11.2x
> > > video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
> > > muxing overhead: 11.128063%
> > > the file is the same
> >
> >
> > Thanks for pointing this out! I have noticed the change in the stats but
> I
> > think the change is correct. Before my patch, the bitrate calculation is
> > based on total_size as in
> >
> > > oc = output_files[0]->ctx;
> > > total_size = avio_size(oc->pb);
> >
> > If I understand this correctly, the size of whole file will be used to
> > calculate the bitrate which considers probably header overhead.
> >
> > I changed it to
> >
> > > total_size = ost->data_size;
> >
> > Therefore only the size of the stream under consideration will be used
> for
> > calculation.
> >
> > Please correct me if my understanding is wrong. Thanks!
>
> Do i understand correctly that you suggest to remove the display of the
> filesize and file bitrate ?
> And in its place would be a display of a randomly picked stream bitrate ?
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> If you fake or manipulate statistics in a paper in physics you will never
> get a job again.
> If you fake or manipulate statistics in a paper in medicin you will get
> a job for life at the pharma industry.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


-- 
Wang Cao
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-07-12 Thread Michael Niedermayer
On Wed, Jul 11, 2018 at 03:47:45PM -0700, Wang Cao wrote:
> >
> > This changes the printed values
> > ./ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -qscale 2  -vframes 3 -an
> > test2.avi
> > frame=3 fps=0.0 q=2.0 Lsize=  51kB time=00:00:00.12
> > bitrate=3495.7kbits/s speed=  12x
> > video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
> > muxing overhead: 11.128063%
> > vs.
> > frame=3 fps=0.0 q=2.0 Lsize=  57kB time=00:00:00.12
> > bitrate=3884.7kbits/s speed=11.2x
> > video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
> > muxing overhead: 11.128063%
> > the file is the same
> 
> 
> Thanks for pointing this out! I have noticed the change in the stats but I
> think the change is correct. Before my patch, the bitrate calculation is
> based on total_size as in
> 
> > oc = output_files[0]->ctx;
> > total_size = avio_size(oc->pb);
> 
> If I understand this correctly, the size of whole file will be used to
> calculate the bitrate which considers probably header overhead.
> 
> I changed it to
> 
> > total_size = ost->data_size;
> 
> Therefore only the size of the stream under consideration will be used for
> calculation.
> 
> Please correct me if my understanding is wrong. Thanks!

Do i understand correctly that you suggest to remove the display of the
filesize and file bitrate ?
And in its place would be a display of a randomly picked stream bitrate ?


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-06-29 Thread Michael Niedermayer
On Fri, Jun 22, 2018 at 04:03:38PM +0800, Wang Cao wrote:
> Make ffmpeg to output stats for each video/audio streams and each ouptut file 
> ffmpeg output log in print_report. The report of video/audio sizes is clear 
> now as previously all output video/audio sizes were combined to report and it 
> is unclear such stats is for one output files or aggregates for all output 
> files.
> 
> Signed-off-by: Wang Cao 
> ---
>  fftools/ffmpeg.c | 52 +---
>  1 file changed, 36 insertions(+), 16 deletions(-)

This changes the printed values
./ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -qscale 2  -vframes 3 -an  test2.avi

frame=3 fps=0.0 q=2.0 Lsize=  51kB time=00:00:00.12 
bitrate=3495.7kbits/s speed=  12x
video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing 
overhead: 11.128063%

vs.

frame=3 fps=0.0 q=2.0 Lsize=  57kB time=00:00:00.12 
bitrate=3884.7kbits/s speed=11.2x
video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing 
overhead: 11.128063%

the file is the same 

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-06-28 Thread Wang Cao
Friendly ping. Thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-06-22 Thread Wang Cao
Make ffmpeg to output stats for each video/audio streams and each ouptut file 
ffmpeg output log in print_report. The report of video/audio sizes is clear now 
as previously all output video/audio sizes were combined to report and it is 
unclear such stats is for one output files or aggregates for all output files.

Signed-off-by: Wang Cao 
---
 fftools/ffmpeg.c | 52 +---
 1 file changed, 36 insertions(+), 16 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d4ac6903cc..321f7a6017 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1530,17 +1530,27 @@ static int reap_filters(int flush)
 return 0;
 }
 
-static void print_final_stats(int64_t total_size)
+static void print_final_stats(void)
 {
 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
 uint64_t subtitle_size = 0;
 uint64_t data_size = 0;
+int64_t total_size;
 float percent = -1.0;
 int i, j;
 int pass1_used = 1;
+AVFormatContext *oc;
 
 for (i = 0; i < nb_output_streams; i++) {
 OutputStream *ost = output_streams[i];
+if (i > 0 && ost->file_index != output_streams[i-1]->file_index) {
+video_size = 0;
+audio_size = 0;
+extra_size = 0;
+other_size = 0;
+subtitle_size = 0;
+data_size = 0;
+}
 switch (ost->enc_ctx->codec_type) {
 case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break;
 case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break;
@@ -1552,7 +1562,13 @@ static void print_final_stats(int64_t total_size)
 if (   (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | 
AV_CODEC_FLAG_PASS2))
 != AV_CODEC_FLAG_PASS1)
 pass1_used = 0;
-}
+
+// Print stats for each output file.
+if (i == nb_output_streams-1 || ost->file_index != 
output_streams[i+1]->file_index) {
+oc = output_files[ost->file_index]->ctx; 
+total_size =  avio_size(oc->pb);
+if (total_size <= 0) // FIXME improve avio_size() so it works with 
non seekable output too
+total_size = avio_tell(oc->pb);
 
 if (data_size && total_size>0 && total_size >= data_size)
 percent = 100.0 * (total_size - data_size) / data_size;
@@ -1568,6 +1584,8 @@ 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++) {
@@ -1651,7 +1669,6 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 {
 AVBPrint buf, buf_script;
 OutputStream *ost;
-AVFormatContext *oc;
 int64_t total_size;
 AVCodecContext *enc;
 int frame_number, vid, i;
@@ -1680,13 +1697,6 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 
 t = (cur_time-timer_start) / 100.0;
 
-
-oc = output_files[0]->ctx;
-
-total_size = avio_size(oc->pb);
-if (total_size <= 0) // FIXME improve avio_size() so it works with non 
seekable output too
-total_size = avio_tell(oc->pb);
-
 vid = 0;
 av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(_script, 0, 1);
@@ -1697,12 +1707,13 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 if (!ost->stream_copy)
 q = ost->quality / (float) FF_QP2LAMBDA;
 
-if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report && vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 av_bprintf(, "q=%2.1f ", q);
 av_bprintf(_script, "stream_%d_%d_q=%.1f\n",
ost->file_index, ost->index, q);
 }
-if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report || !is_last_report && !vid) {
+if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 float fps;
 
 frame_number = ost->frame_number;
@@ -1759,9 +1770,11 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 if (av_stream_get_end_pts(ost->st) != AV_NOPTS_VALUE)
 pts = FFMAX(pts, av_rescale_q(av_stream_get_end_pts(ost->st),
   ost->st->time_base, AV_TIME_BASE_Q));
-if (is_last_report)
+if (is_last_report) {
 nb_frames_drop += ost->last_dropped;
-}
+}
+
+total_size = ost->data_size;
 
 secs = FFABS(pts) / AV_TIME_BASE;
 us = FFABS(pts) % AV_TIME_BASE;
@@ -1815,8 +1828,15 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 av_bprintf(_script, "speed=%4.3gx\n", speed);
 }
 
+if (is_last_report)
+av_bprintf(, "\n");
+   else if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
+   

Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-06-21 Thread Michael Niedermayer
On Fri, Jun 15, 2018 at 01:37:31PM +0800, Wang Cao wrote:
> Make ffmpeg to output stats for each video/audio streams and each ouptut file 
> ffmpeg output log in print_report. The report of video/audio sizes is clear 
> now as previously all output video/audio sizes were combined to report and it 
> is unclear such stats is for one output files or aggregates for all output 
> files.
> 
> Signed-off-by: Wang Cao 
> ---
>  fftools/ffmpeg.c | 45 +++--
>  1 file changed, 31 insertions(+), 14 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index d4ac6903cc..1eaf344552 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -1530,17 +1530,27 @@ static int reap_filters(int flush)
>  return 0;
>  }
>  
> -static void print_final_stats(int64_t total_size)
> +static void print_final_stats()
>  {

there are some new warnings:

fftools/ffmpeg.c:1533:13: warning: function declaration isn’t a prototype 
[-Wstrict-prototypes]
 static void print_final_stats()
 ^
fftools/ffmpeg.c: In function ‘print_report’:
fftools/ffmpeg.c:1672:22: warning: unused variable ‘oc’ [-Wunused-variable]
 AVFormatContext *oc;
  ^
[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream - Make ffmpeg to output stats for each video/audio streams and each ouptut file ffmpeg output log in print_repor

2018-06-20 Thread Wang Cao
Thanks for letting me know about this. I actually submitted another patch
without long commit message. I will clean up according to your feedback
after getting feedbacks from other people.

On Sat, Jun 16, 2018 at 2:52 AM Michael Niedermayer 
wrote:

> On Thu, Jun 14, 2018 at 08:35:48PM +0800, Wang Cao wrote:
> > Signed-off-by: Wang Cao 
> > ---
> >  fftools/ffmpeg.c | 45 +++--
> >  1 file changed, 31 insertions(+), 14 deletions(-)
>
> this adds some warnings:
>
> CC  fftools/ffmpeg.o
> fftools/ffmpeg.c:1533:13: warning: function declaration isn’t a prototype
> [-Wstrict-prototypes]
>  static void print_final_stats()
>  ^
> fftools/ffmpeg.c: In function ‘print_report’:
> fftools/ffmpeg.c:1672:22: warning: unused variable ‘oc’ [-Wunused-variable]
>  AVFormatContext *oc;
>   ^
>
> also the commit message should not be one very long line
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> What does censorship reveal? It reveals fear. -- Julian Assange
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


-- 
Wang Cao
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-06-20 Thread Wang Cao
Make ffmpeg to output stats for each video/audio streams and each ouptut file 
ffmpeg output log in print_report. The report of video/audio sizes is clear now 
as previously all output video/audio sizes were combined to report and it is 
unclear such stats is for one output files or aggregates for all output files.

Signed-off-by: Wang Cao 
---
 fftools/ffmpeg.c | 47 +--
 1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d4ac6903cc..1842ccd543 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1530,17 +1530,27 @@ static int reap_filters(int flush)
 return 0;
 }
 
-static void print_final_stats(int64_t total_size)
+static void print_final_stats()
 {
 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
 uint64_t subtitle_size = 0;
 uint64_t data_size = 0;
+int64_t total_size;
 float percent = -1.0;
 int i, j;
 int pass1_used = 1;
+AVFormatContext *oc;
 
 for (i = 0; i < nb_output_streams; i++) {
 OutputStream *ost = output_streams[i];
+if (i > 0 && ost->file_index != output_streams[i-1]->file_index) {
+video_size = 0;
+audio_size = 0;
+extra_size = 0;
+other_size = 0;
+subtitle_size = 0;
+data_size = 0;
+}
 switch (ost->enc_ctx->codec_type) {
 case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break;
 case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break;
@@ -1552,7 +1562,13 @@ static void print_final_stats(int64_t total_size)
 if (   (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | 
AV_CODEC_FLAG_PASS2))
 != AV_CODEC_FLAG_PASS1)
 pass1_used = 0;
-}
+
+// Print stats for each output file.
+if (i == nb_output_streams-1 || ost->file_index != 
output_streams[i+1]->file_index) {
+oc = output_files[ost->file_index]->ctx; 
+total_size =  avio_size(oc->pb);
+if (total_size <= 0) // FIXME improve avio_size() so it works with 
non seekable output too
+total_size = avio_tell(oc->pb);
 
 if (data_size && total_size>0 && total_size >= data_size)
 percent = 100.0 * (total_size - data_size) / data_size;
@@ -1568,6 +1584,8 @@ 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++) {
@@ -1680,13 +1698,6 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 
 t = (cur_time-timer_start) / 100.0;
 
-
-oc = output_files[0]->ctx;
-
-total_size = avio_size(oc->pb);
-if (total_size <= 0) // FIXME improve avio_size() so it works with non 
seekable output too
-total_size = avio_tell(oc->pb);
-
 vid = 0;
 av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(_script, 0, 1);
@@ -1697,12 +1708,13 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 if (!ost->stream_copy)
 q = ost->quality / (float) FF_QP2LAMBDA;
 
-if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report && vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 av_bprintf(, "q=%2.1f ", q);
 av_bprintf(_script, "stream_%d_%d_q=%.1f\n",
ost->file_index, ost->index, q);
 }
-if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report || !is_last_report && !vid) {
+if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 float fps;
 
 frame_number = ost->frame_number;
@@ -1761,7 +1773,7 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
   ost->st->time_base, AV_TIME_BASE_Q));
 if (is_last_report)
 nb_frames_drop += ost->last_dropped;
-}
+total_size = ost->data_size;
 
 secs = FFABS(pts) / AV_TIME_BASE;
 us = FFABS(pts) % AV_TIME_BASE;
@@ -1815,8 +1827,15 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 av_bprintf(_script, "speed=%4.3gx\n", speed);
 }
 
+if (is_last_report)
+av_bprintf(, "\n");
+   else if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
+av_bprintf(, "\r");
+   }
+}
+
 if (print_stats || is_last_report) {
-const char end = is_last_report ? '\n' : '\r';
+const char end = '\r';
 if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
 fprintf(stderr, "%s%c", buf.str, end);
 } else
@@ -1841,7 +1860,7 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 }
 
 if (is_last_report)
-  

Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream - Make ffmpeg to output stats for each video/audio streams and each ouptut file ffmpeg output log in print_repor

2018-06-15 Thread Michael Niedermayer
On Thu, Jun 14, 2018 at 08:35:48PM +0800, Wang Cao wrote:
> Signed-off-by: Wang Cao 
> ---
>  fftools/ffmpeg.c | 45 +++--
>  1 file changed, 31 insertions(+), 14 deletions(-)

this adds some warnings:

CC  fftools/ffmpeg.o
fftools/ffmpeg.c:1533:13: warning: function declaration isn’t a prototype 
[-Wstrict-prototypes]
 static void print_final_stats()
 ^
fftools/ffmpeg.c: In function ‘print_report’:
fftools/ffmpeg.c:1672:22: warning: unused variable ‘oc’ [-Wunused-variable]
 AVFormatContext *oc;
  ^
  
also the commit message should not be one very long line

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-06-15 Thread Moritz Barsnick
On Fri, Jun 15, 2018 at 13:37:31 +0800, Wang Cao wrote:

> Make ffmpeg to output stats for each video/audio streams and each
> ouptut file ffmpeg output log in print_report. The report of
> video/audio sizes is clear now as previously all output video/audio
> sizes were combined to report and it is unclear such stats is for one
> output files or aggregates for all output files.

(This needs some cleaing up of the grammar, but that's beside the point
right now.)

Somehow, this changes the stats while running. I no longer see the
overall stats. If I map video first, I see only the video stats, but it
seems like the audio stats flicker through. If I map audio first, I see
a duplicated line (extended), which shows video and audio stat lines
side by side.

I don't think this is what you intended. You only wanted to show the
*final* stats differently, correct? If it is intended, I'd like to
point out that the status line does not have enough space on most
screens to hold twice or more of its current content. I would still
like to see overall stats, also at the end, because it says something
about e.g. the total size. In the summary report, per file and per
stream stats may be nice though.

Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-06-14 Thread Wang Cao
Make ffmpeg to output stats for each video/audio streams and each ouptut file 
ffmpeg output log in print_report. The report of video/audio sizes is clear now 
as previously all output video/audio sizes were combined to report and it is 
unclear such stats is for one output files or aggregates for all output files.

Signed-off-by: Wang Cao 
---
 fftools/ffmpeg.c | 45 +++--
 1 file changed, 31 insertions(+), 14 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d4ac6903cc..1eaf344552 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1530,17 +1530,27 @@ static int reap_filters(int flush)
 return 0;
 }
 
-static void print_final_stats(int64_t total_size)
+static void print_final_stats()
 {
 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
 uint64_t subtitle_size = 0;
 uint64_t data_size = 0;
+int64_t total_size;
 float percent = -1.0;
 int i, j;
 int pass1_used = 1;
+AVFormatContext *oc;
 
 for (i = 0; i < nb_output_streams; i++) {
 OutputStream *ost = output_streams[i];
+if (i > 0 && ost->file_index != output_streams[i-1]->file_index) {
+video_size = 0;
+audio_size = 0;
+extra_size = 0;
+other_size = 0;
+subtitle_size = 0;
+data_size = 0;
+}
 switch (ost->enc_ctx->codec_type) {
 case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break;
 case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break;
@@ -1552,7 +1562,13 @@ static void print_final_stats(int64_t total_size)
 if (   (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | 
AV_CODEC_FLAG_PASS2))
 != AV_CODEC_FLAG_PASS1)
 pass1_used = 0;
-}
+
+// Print stats for each output file.
+if (i == nb_output_streams-1 || ost->file_index != 
output_streams[i+1]->file_index) {
+oc = output_files[ost->file_index]->ctx; 
+total_size =  avio_size(oc->pb);
+if (total_size <= 0) // FIXME improve avio_size() so it works with 
non seekable output too
+total_size = avio_tell(oc->pb);
 
 if (data_size && total_size>0 && total_size >= data_size)
 percent = 100.0 * (total_size - data_size) / data_size;
@@ -1568,6 +1584,8 @@ 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++) {
@@ -1680,13 +1698,6 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 
 t = (cur_time-timer_start) / 100.0;
 
-
-oc = output_files[0]->ctx;
-
-total_size = avio_size(oc->pb);
-if (total_size <= 0) // FIXME improve avio_size() so it works with non 
seekable output too
-total_size = avio_tell(oc->pb);
-
 vid = 0;
 av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(_script, 0, 1);
@@ -1697,12 +1708,13 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 if (!ost->stream_copy)
 q = ost->quality / (float) FF_QP2LAMBDA;
 
-if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report && vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 av_bprintf(, "q=%2.1f ", q);
 av_bprintf(_script, "stream_%d_%d_q=%.1f\n",
ost->file_index, ost->index, q);
 }
-if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report || !is_last_report && !vid) {
+if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 float fps;
 
 frame_number = ost->frame_number;
@@ -1761,7 +1773,7 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
   ost->st->time_base, AV_TIME_BASE_Q));
 if (is_last_report)
 nb_frames_drop += ost->last_dropped;
-}
+total_size = ost->data_size;
 
 secs = FFABS(pts) / AV_TIME_BASE;
 us = FFABS(pts) % AV_TIME_BASE;
@@ -1815,8 +1827,13 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 av_bprintf(_script, "speed=%4.3gx\n", speed);
 }
 
+if (is_last_report)
+av_bprintf(, "\n");
+   }
+}
+
 if (print_stats || is_last_report) {
-const char end = is_last_report ? '\n' : '\r';
+const char end = '\r';
 if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
 fprintf(stderr, "%s%c", buf.str, end);
 } else
@@ -1841,7 +1858,7 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 }
 
 if (is_last_report)
-print_final_stats(total_size);
+print_final_stats();
 }
 
 static void 

[FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream - Make ffmpeg to output stats for each video/audio streams and each ouptut file ffmpeg output log in print_report. T

2018-06-14 Thread Wang Cao
Signed-off-by: Wang Cao 
---
 fftools/ffmpeg.c | 45 +++--
 1 file changed, 31 insertions(+), 14 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d4ac6903cc..1eaf344552 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1530,17 +1530,27 @@ static int reap_filters(int flush)
 return 0;
 }
 
-static void print_final_stats(int64_t total_size)
+static void print_final_stats()
 {
 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
 uint64_t subtitle_size = 0;
 uint64_t data_size = 0;
+int64_t total_size;
 float percent = -1.0;
 int i, j;
 int pass1_used = 1;
+AVFormatContext *oc;
 
 for (i = 0; i < nb_output_streams; i++) {
 OutputStream *ost = output_streams[i];
+if (i > 0 && ost->file_index != output_streams[i-1]->file_index) {
+video_size = 0;
+audio_size = 0;
+extra_size = 0;
+other_size = 0;
+subtitle_size = 0;
+data_size = 0;
+}
 switch (ost->enc_ctx->codec_type) {
 case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break;
 case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break;
@@ -1552,7 +1562,13 @@ static void print_final_stats(int64_t total_size)
 if (   (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | 
AV_CODEC_FLAG_PASS2))
 != AV_CODEC_FLAG_PASS1)
 pass1_used = 0;
-}
+
+// Print stats for each output file.
+if (i == nb_output_streams-1 || ost->file_index != 
output_streams[i+1]->file_index) {
+oc = output_files[ost->file_index]->ctx; 
+total_size =  avio_size(oc->pb);
+if (total_size <= 0) // FIXME improve avio_size() so it works with 
non seekable output too
+total_size = avio_tell(oc->pb);
 
 if (data_size && total_size>0 && total_size >= data_size)
 percent = 100.0 * (total_size - data_size) / data_size;
@@ -1568,6 +1584,8 @@ 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++) {
@@ -1680,13 +1698,6 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 
 t = (cur_time-timer_start) / 100.0;
 
-
-oc = output_files[0]->ctx;
-
-total_size = avio_size(oc->pb);
-if (total_size <= 0) // FIXME improve avio_size() so it works with non 
seekable output too
-total_size = avio_tell(oc->pb);
-
 vid = 0;
 av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(_script, 0, 1);
@@ -1697,12 +1708,13 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 if (!ost->stream_copy)
 q = ost->quality / (float) FF_QP2LAMBDA;
 
-if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report && vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 av_bprintf(, "q=%2.1f ", q);
 av_bprintf(_script, "stream_%d_%d_q=%.1f\n",
ost->file_index, ost->index, q);
 }
-if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report || !is_last_report && !vid) {
+if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 float fps;
 
 frame_number = ost->frame_number;
@@ -1761,7 +1773,7 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
   ost->st->time_base, AV_TIME_BASE_Q));
 if (is_last_report)
 nb_frames_drop += ost->last_dropped;
-}
+total_size = ost->data_size;
 
 secs = FFABS(pts) / AV_TIME_BASE;
 us = FFABS(pts) % AV_TIME_BASE;
@@ -1815,8 +1827,13 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 av_bprintf(_script, "speed=%4.3gx\n", speed);
 }
 
+if (is_last_report)
+av_bprintf(, "\n");
+   }
+}
+
 if (print_stats || is_last_report) {
-const char end = is_last_report ? '\n' : '\r';
+const char end = '\r';
 if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
 fprintf(stderr, "%s%c", buf.str, end);
 } else
@@ -1841,7 +1858,7 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 }
 
 if (is_last_report)
-print_final_stats(total_size);
+print_final_stats();
 }
 
 static void ifilter_parameters_from_codecpar(InputFilter *ifilter, 
AVCodecParameters *par)
-- 
2.18.0.rc1.242.g61856ae69a-goog

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-05-25 Thread Michael Niedermayer
On Tue, May 22, 2018 at 03:40:54PM -0700, Wang Cao wrote:
> - Make ffmpeg to output stats for each video/audio streams and each ouptut 
> file ffmpeg output log in print_report.
> - The report of video/audio sizes is clear as previously all output
> video/audio sizes were combined to report and it is unclear such stats
> is for one output files or aggregates for all output files.
> 
> Signed-off-by: Wang Cao 
> ---
>  fftools/ffmpeg.c | 65 
>  1 file changed, 44 insertions(+), 21 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 5a19a09d9a..0b98521852 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -1526,17 +1526,28 @@ static int reap_filters(int flush)
>  return 0;
>  }
>  
> -static void print_final_stats(int64_t total_size)
> +static void print_final_stats()
>  {
>  uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
>  uint64_t subtitle_size = 0;
>  uint64_t data_size = 0;
> +int64_t total_size;
>  float percent = -1.0;
>  int i, j;
>  int pass1_used = 1;
> +AVFormatContext *oc;
>  
>  for (i = 0; i < nb_output_streams; i++) {
>  OutputStream *ost = output_streams[i];
> +if (i > 0 && ost->file_index != output_streams[i-1]->file_index) {
> +video_size = 0;
> +audio_size = 0;
> +extra_size = 0;
> +other_size = 0;
> +subtitle_size = 0;
> +data_size = 0;
> +}
> +
>  switch (ost->enc_ctx->codec_type) {
>  case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break;
>  case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break;
> @@ -1545,25 +1556,37 @@ static void print_final_stats(int64_t total_size)
>  }
>  extra_size += ost->enc_ctx->extradata_size;
>  data_size  += ost->data_size;
> +
>  if (   (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | 
> AV_CODEC_FLAG_PASS2))
>  != AV_CODEC_FLAG_PASS1)
>  pass1_used = 0;
> -}
> -
> +
> +// Print stats for each output file.
> +if (i == nb_output_streams-1 || ost->file_index != 
> output_streams[i+1]->file_index) {
> +oc = output_files[ost->file_index]->ctx; 
> +total_size =  avio_size(oc->pb);
> +if (total_size <= 0) // FIXME improve avio_size() so it works 
> with non seekable output too
> +total_size = avio_tell(oc->pb);
> +
>  if (data_size && total_size>0 && total_size >= data_size)
>  percent = 100.0 * (total_size - data_size) / data_size;

> -
> +

Adding trailing whitespace



>  av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB subtitle:%1.0fkB 
> other streams:%1.0fkB global headers:%1.0fkB muxing overhead: ",
> video_size / 1024.0,
> audio_size / 1024.0,
> subtitle_size / 1024.0,
> other_size / 1024.0,
> extra_size / 1024.0);
> +   
>  if (percent >= 0.0)

not related, whitespace change


>  av_log(NULL, AV_LOG_INFO, "%f%%", percent);
>  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++) {
> @@ -1676,13 +1699,6 @@ static void print_report(int is_last_report, int64_t 
> timer_start, int64_t cur_ti
>  
>  t = (cur_time-timer_start) / 100.0;
>  
> -
> -oc = output_files[0]->ctx;
> -
> -total_size = avio_size(oc->pb);
> -if (total_size <= 0) // FIXME improve avio_size() so it works with non 
> seekable output too
> -total_size = avio_tell(oc->pb);
> -
>  vid = 0;
>  av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
>  av_bprint_init(_script, 0, 1);
> @@ -1693,12 +1709,13 @@ static void print_report(int is_last_report, int64_t 
> timer_start, int64_t cur_ti
>  if (!ost->stream_copy)
>  q = ost->quality / (float) FF_QP2LAMBDA;
>  
> -if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
> +if (is_last_report && vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
>  av_bprintf(, "q=%2.1f ", q);
>  av_bprintf(_script, "stream_%d_%d_q=%.1f\n",
> ost->file_index, ost->index, q);
>  }
> -if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
> +if (is_last_report || !is_last_report && !vid) {
> +if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
>  float fps;
>  
>  frame_number = ost->frame_number;
> @@ -1750,14 +1767,16 @@ static void print_report(int is_last_report, int64_t 
> timer_start, int64_t cur_ti
> ost->file_index, ost->index, p);
>  }
>  vid = 1;
> -}
> +}
> +

>  /* compute min output 

[FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-05-22 Thread Wang Cao
- Make ffmpeg to output stats for each video/audio streams and each ouptut file 
ffmpeg output log in print_report.
- The report of video/audio sizes is clear as previously all output
video/audio sizes were combined to report and it is unclear such stats
is for one output files or aggregates for all output files.

Signed-off-by: Wang Cao 
---
 fftools/ffmpeg.c | 65 
 1 file changed, 44 insertions(+), 21 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5a19a09d9a..0b98521852 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1526,17 +1526,28 @@ static int reap_filters(int flush)
 return 0;
 }
 
-static void print_final_stats(int64_t total_size)
+static void print_final_stats()
 {
 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
 uint64_t subtitle_size = 0;
 uint64_t data_size = 0;
+int64_t total_size;
 float percent = -1.0;
 int i, j;
 int pass1_used = 1;
+AVFormatContext *oc;
 
 for (i = 0; i < nb_output_streams; i++) {
 OutputStream *ost = output_streams[i];
+if (i > 0 && ost->file_index != output_streams[i-1]->file_index) {
+video_size = 0;
+audio_size = 0;
+extra_size = 0;
+other_size = 0;
+subtitle_size = 0;
+data_size = 0;
+}
+
 switch (ost->enc_ctx->codec_type) {
 case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break;
 case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break;
@@ -1545,25 +1556,37 @@ static void print_final_stats(int64_t total_size)
 }
 extra_size += ost->enc_ctx->extradata_size;
 data_size  += ost->data_size;
+
 if (   (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | 
AV_CODEC_FLAG_PASS2))
 != AV_CODEC_FLAG_PASS1)
 pass1_used = 0;
-}
-
+
+// Print stats for each output file.
+if (i == nb_output_streams-1 || ost->file_index != 
output_streams[i+1]->file_index) {
+oc = output_files[ost->file_index]->ctx; 
+total_size =  avio_size(oc->pb);
+if (total_size <= 0) // FIXME improve avio_size() so it works with 
non seekable output too
+total_size = avio_tell(oc->pb);
+
 if (data_size && total_size>0 && total_size >= data_size)
 percent = 100.0 * (total_size - data_size) / data_size;
-
+
 av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB subtitle:%1.0fkB 
other streams:%1.0fkB global headers:%1.0fkB muxing overhead: ",
video_size / 1024.0,
audio_size / 1024.0,
subtitle_size / 1024.0,
other_size / 1024.0,
extra_size / 1024.0);
+   
 if (percent >= 0.0)
 av_log(NULL, AV_LOG_INFO, "%f%%", percent);
 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++) {
@@ -1676,13 +1699,6 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 
 t = (cur_time-timer_start) / 100.0;
 
-
-oc = output_files[0]->ctx;
-
-total_size = avio_size(oc->pb);
-if (total_size <= 0) // FIXME improve avio_size() so it works with non 
seekable output too
-total_size = avio_tell(oc->pb);
-
 vid = 0;
 av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(_script, 0, 1);
@@ -1693,12 +1709,13 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 if (!ost->stream_copy)
 q = ost->quality / (float) FF_QP2LAMBDA;
 
-if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report && vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 av_bprintf(, "q=%2.1f ", q);
 av_bprintf(_script, "stream_%d_%d_q=%.1f\n",
ost->file_index, ost->index, q);
 }
-if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report || !is_last_report && !vid) {
+if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 float fps;
 
 frame_number = ost->frame_number;
@@ -1750,14 +1767,16 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
ost->file_index, ost->index, p);
 }
 vid = 1;
-}
+}
+
 /* compute min output value */
 if (av_stream_get_end_pts(ost->st) != AV_NOPTS_VALUE)
 pts = FFMAX(pts, av_rescale_q(av_stream_get_end_pts(ost->st),
-  ost->st->time_base, AV_TIME_BASE_Q));
+  ost->st->time_base, AV_TIME_BASE_Q));
 if (is_last_report)
 nb_frames_drop += ost->last_dropped;
-}
+

Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-05-21 Thread Michael Niedermayer
On Mon, May 21, 2018 at 02:36:28PM -0700, Wang Cao wrote:
> Sorry the ticket doesn't contain alaw_2.aif as in
> https://trac.ffmpeg.org/ticket/1660

the issue is reproduceable with alaw.aif from the ticket

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-05-21 Thread Wang Cao
Sorry the ticket doesn't contain alaw_2.aif as in
https://trac.ffmpeg.org/ticket/1660

On Fri, May 18, 2018 at 8:13 PM, Michael Niedermayer  wrote:

> On Fri, May 18, 2018 at 04:54:25PM -0700, Wang Cao wrote:
> > - Make ffmpeg to output stats for each video streams and each ouptut
> file ffmpeg output log in print_report.
> > - The report of video/audio sizes is clear as previously all output
> > video/audio sizes were combined to report and it is unclear such stats
> > is for one output files or aggregates for all output files.
> >
> > Signed-off-by: Wang Cao 
> > ---
> >  fftools/ffmpeg.c | 182 ++-
> >  1 file changed, 101 insertions(+), 81 deletions(-)
>
> This causes the report to disappear for
> ./ffmpeg -i ~/tickets/1660/alaw_2.aif -f null -
>
> file should be in the ticket on trac, if not, say so and ill figure out
> where
> the file is
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Those who are best at talking, realize last or never when they are wrong.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>


-- 
Wang Cao
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-05-19 Thread Moritz Barsnick
On Fri, May 18, 2018 at 16:54:25 -0700, Wang Cao wrote:

Apart from the functional changes:

>  data_size  += ost->data_size;
> -if (   (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | 
> AV_CODEC_FLAG_PASS2))
> +
> +if ((ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | 
> AV_CODEC_FLAG_PASS2))
>  != AV_CODEC_FLAG_PASS1)

> -if (nb_frames_dup || nb_frames_drop)
> -av_bprintf(, " dup=%d drop=%d", nb_frames_dup, nb_frames_drop);
> -av_bprintf(_script, "dup_frames=%d\n", nb_frames_dup);
> -av_bprintf(_script, "drop_frames=%d\n", nb_frames_drop);
> +if (nb_frames_dup || nb_frames_drop)
> +av_bprintf(, " dup=%d drop=%d", nb_frames_dup, 
> nb_frames_drop);
> +av_bprintf(_script, "dup_frames=%d\n", nb_frames_dup);
> +av_bprintf(_script, "drop_frames=%d\n", nb_frames_drop);
>  

> -
> -fflush(stderr);
> +fflush(stderr);
>  }

>  }
> -
>  if (is_last_report)

A lot of your changes are cosmetic (empty lines, re-indentation) and do
not belong into a functional patch, if at all.

Furthermore, some large sections are reindented due to moving into or
out of a block. Please avoid that, and make the indentations in a
subsequent patch, to ease review.

Thanks,
Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-05-18 Thread Michael Niedermayer
On Fri, May 18, 2018 at 04:54:25PM -0700, Wang Cao wrote:
> - Make ffmpeg to output stats for each video streams and each ouptut file 
> ffmpeg output log in print_report.
> - The report of video/audio sizes is clear as previously all output
> video/audio sizes were combined to report and it is unclear such stats
> is for one output files or aggregates for all output files.
> 
> Signed-off-by: Wang Cao 
> ---
>  fftools/ffmpeg.c | 182 ++-
>  1 file changed, 101 insertions(+), 81 deletions(-)

This causes the report to disappear for
./ffmpeg -i ~/tickets/1660/alaw_2.aif -f null -

file should be in the ticket on trac, if not, say so and ill figure out where
the file is

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are best at talking, realize last or never when they are wrong.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-05-18 Thread Wang Cao
- Make ffmpeg to output stats for each video streams and each ouptut file 
ffmpeg output log in print_report.
- The report of video/audio sizes is clear as previously all output
video/audio sizes were combined to report and it is unclear such stats
is for one output files or aggregates for all output files.

Signed-off-by: Wang Cao 
---
 fftools/ffmpeg.c | 182 ++-
 1 file changed, 101 insertions(+), 81 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5a19a09d9a..4aa6c1d3e4 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1526,17 +1526,28 @@ static int reap_filters(int flush)
 return 0;
 }
 
-static void print_final_stats(int64_t total_size)
+static void print_final_stats()
 {
 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
 uint64_t subtitle_size = 0;
 uint64_t data_size = 0;
+int64_t total_size;
 float percent = -1.0;
 int i, j;
 int pass1_used = 1;
+AVFormatContext *oc;
 
 for (i = 0; i < nb_output_streams; i++) {
 OutputStream *ost = output_streams[i];
+if (i > 0 && ost->file_index != output_streams[i-1]->file_index) {
+video_size = 0;
+audio_size = 0;
+extra_size = 0;
+other_size = 0;
+subtitle_size = 0;
+data_size = 0;
+}
+
 switch (ost->enc_ctx->codec_type) {
 case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break;
 case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break;
@@ -1545,25 +1556,37 @@ static void print_final_stats(int64_t total_size)
 }
 extra_size += ost->enc_ctx->extradata_size;
 data_size  += ost->data_size;
-if (   (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | 
AV_CODEC_FLAG_PASS2))
+
+if ((ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2))
 != AV_CODEC_FLAG_PASS1)
 pass1_used = 0;
+
+// Print stats for each output file.
+if (i == nb_output_streams-1 || ost->file_index != 
output_streams[i+1]->file_index) {
+oc = output_files[ost->file_index]->ctx; 
+total_size =  avio_size(oc->pb);
+if (total_size <= 0) // FIXME improve avio_size() so it works with 
non seekable output too
+total_size = avio_tell(oc->pb);
+
+if (data_size && total_size>0 && total_size >= data_size)
+percent = 100.0 * (total_size - data_size) / data_size;
+
+av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB 
subtitle:%1.0fkB other streams:%1.0fkB global headers:%1.0fkB muxing overhead: 
",
+   video_size / 1024.0,
+   audio_size / 1024.0,
+   subtitle_size / 1024.0,
+   other_size / 1024.0,
+   extra_size / 1024.0);
+   
+if (percent >= 0.0)
+av_log(NULL, AV_LOG_INFO, "%f%%", percent);
+else
+av_log(NULL, AV_LOG_INFO, "unknown");
+av_log(NULL, AV_LOG_INFO, "\n");
+}
 }
 
-if (data_size && total_size>0 && total_size >= data_size)
-percent = 100.0 * (total_size - data_size) / data_size;
 
-av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB subtitle:%1.0fkB 
other streams:%1.0fkB global headers:%1.0fkB muxing overhead: ",
-   video_size / 1024.0,
-   audio_size / 1024.0,
-   subtitle_size / 1024.0,
-   other_size / 1024.0,
-   extra_size / 1024.0);
-if (percent >= 0.0)
-av_log(NULL, AV_LOG_INFO, "%f%%", percent);
-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++) {
@@ -1676,13 +1699,6 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 
 t = (cur_time-timer_start) / 100.0;
 
-
-oc = output_files[0]->ctx;
-
-total_size = avio_size(oc->pb);
-if (total_size <= 0) // FIXME improve avio_size() so it works with non 
seekable output too
-total_size = avio_tell(oc->pb);
-
 vid = 0;
 av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(_script, 0, 1);
@@ -1693,12 +1709,12 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 if (!ost->stream_copy)
 q = ost->quality / (float) FF_QP2LAMBDA;
 
-if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (is_last_report && vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 av_bprintf(, "q=%2.1f ", q);
 av_bprintf(_script, "stream_%d_%d_q=%.1f\n",
ost->file_index, ost->index, q);
 }
-if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (enc->codec_type == AVMEDIA_TYPE_VIDEO &&