silicontrip / lavtools

mjpeg utils and avcodec frame based video editing tools and ffmpeg filters
15 stars 3 forks source link

libav-bitrate: option for printing line per second #6

Closed Nikoli closed 11 years ago

Nikoli commented 11 years ago

Now libav-bitrate prints line per frame, in many cases it is not the best output format. Please add option for printing line per second. Format will be:

<time in seconds> <data size for all streams> <data size for stream 1> <data size for stream N>
silicontrip commented 11 years ago

I've added -i and -I to limit the output interval. By default the output interval is in 1 frame, as was it's previous behaviour. -i is specified in frames. eg 25 would be 1 second (PAL) or you can specify the seconds with -I, which simply multiplies this value by the frame rate to calculate the output interval in frames.

Nikoli commented 11 years ago

Thank you, '-I 1' works great! Graphs are much better now. But there is one problem: libav-bitrate segfaults if you run it without any option. Instead it should show same help as when running with --help. If you are not able to reproduce, i will provide gdb output.

Nikoli commented 11 years ago

Second problem: there is no check if -I, -i or -s argument is a number:

/usr/local/bin/libav-bitrate /tmp/sample-001.mkv -I rtdgdfg

Above command should exist with error like 'rtdgdfg is not a number'

silicontrip commented 11 years ago

Yes, I know the bug. I encountered it when testing the -i options. But didn't think much more about it.

Nikoli commented 11 years ago

Which one?

silicontrip commented 11 years ago

The null filename. Both of these have been fixed.

Nikoli commented 11 years ago

'-I rtdgdfg' does not exit with error, '-i rtdgdfg ' crashes with SIGFPE

silicontrip commented 11 years ago

Unlike strtol, strtod does not set errno to EINVAL if a non numeric value is encountered. A value of 0 seconds for the interval is invalid (which is returned if the string is not numeric) and is reported as such.

Nikoli commented 11 years ago

'-I rtdgdfg' is fixed, but '-i rtdgdfg' still crashes. Also '-I 1rtdgdfg' is detected as '-I 1' and does not show any error. Another problem: there is no check if number is not positive or bigger then video length. When number is much bigger, something really strange happens. Did several tests with 270s sample: 1) 'libav-bitrate /tmp/sample-001.mkv -I 250' prints one line as expected: 250.000000 2461800.000000 1945894.464000 253466.016000 253466.848000 2467.904000 2300.288000 4359.040000 0.000000 2) 'libav-bitrate /tmp/sample-001.mkv -I 271' prints no lines as expected. 3) 'sample-001.mkv -I 85900000' prints 6739 lines.

silicontrip commented 11 years ago

I have a suspicion that the really large value overflowed the INT value and made it negative. Thus printing every line.

Thanks for the testing.

Mark

Nikoli commented 11 years ago

Now scan-build (tool from clang-3.1) reports several problems:

/usr/bin/ccc-analyzer  -lswscale -lavcodec -lavformat -lavutil -L/usr/lib -g -I/usr/include/mjpegtools  -I/usr/include/ -I/usr/include/freetype2/ -o libav-bitrate  libav-bitrate.c
libav-bitrate.c:158:2: warning: Value stored to 'argc' is never read
        argc -= optind;
        ^       ~~~~~~
libav-bitrate.c:331:5: warning: Value stored to 'total_size' is never read
                                total_size = 0;
                                ^            ~
2 warnings generated.

Check for small numbers is missing, testing 25 fps video:

/usr/local/bin/libav-bitrate /tmp/sample-001.mkv -I 0.04|grep -c ''
6738
strace /usr/local/bin/libav-bitrate /tmp/sample-001.mkv -I 0.03
--- SIGFPE {si_signo=SIGFPE, si_code=FPE_INTDIV, si_addr=0xd487f4a97} ---
+++ killed by SIGFPE +++

Problems from my previous comment are fixed.