[pHash-support] segfaults and unhashable videos using lt-test_video

Benedikt Fraunhofer given.to.phash.org.toasta.001 at traced.net
Tue Jan 29 10:38:28 PST 2013


Hello List,

hope this list is still alive...
I'm trying to get the current version (0.9.5) running on a "current"
ubuntu  12.04

ii  libavcodec-dev                            4:0.8.4-0ubuntu0.12.04.1
ii  ffmpeg                                    4:0.8.4-0ubuntu0.12.04.1

(this should be ffmpeg 5.3)

The first segfaults of test_video (-> examples/.libs/lt-test_video)
are easily fixed by calling it with at least two arguments (my fault,
didn't read the source :) (it somehow checks the number of arguments
but looks like that's wrong :)

the other two were a bit harder to find, at least for me; they were
caused by unitiliazied AVFormatContext structs.
bf at z:~/pHash-0.9.5$ examples/test_video; gdb --args
/home/bf/pHash-0.9.5/examples/.libs/lt-test_video
/dev/shm/fa/test-video-{a.mp4,b.mkv}
not enough input arguments
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/bf/pHash-0.9.5/examples/.libs/lt-test_video...done.
(gdb) r
Starting program: /home/bf/pHash-0.9.5/examples/.libs/lt-test_video
/dev/shm/fa/test-video-a.mp4 /dev/shm/fa/test-video-b.mkv
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
file1=/dev/shm/fa/test-video-a.mp4

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff65a3d59 in avio_read ()
   from /usr/lib/x86_64-linux-gnu/libavformat.so.53
(gdb) bt
#0  0x00007ffff65a3d59 in avio_read ()
   from /usr/lib/x86_64-linux-gnu/libavformat.so.53
#1  0x00007ffff6624cae in av_probe_input_buffer ()
   from /usr/lib/x86_64-linux-gnu/libavformat.so.53
#2  0x00007ffff662a2e1 in avformat_open_input ()
   from /usr/lib/x86_64-linux-gnu/libavformat.so.53
#3  0x00007ffff7b86f60 in GetNumberVideoFrames (
    file=0x7fffffffe4f1 "/dev/shm/fa/test-video-a.mp4") at cimgffmpeg.cpp:369
#4  0x00007ffff7b3219a in ph_getKeyFramesFromVideo (
    filename=0x7fffffffe4f1 "/dev/shm/fa/test-video-a.mp4") at pHash.cpp:485
#5  0x00007ffff7b32ca6 in ph_dct_videohash (
    filename=0x7fffffffe4f1 "/dev/shm/fa/test-video-a.mp4",
    Length=@0x7fffffffe104: 32767) at pHash.cpp:662
#6  0x0000000000400910 in main (argc=3, argv=0x7fffffffe1f8)
    at test_dctvideohash.cpp:51
(gdb)

(gdb) frame 3
#3  0x00007ffff7b86f60 in GetNumberVideoFrames (
    file=0x7fffffffe4f1 "/dev/shm/fa/test-video-a.mp4") at cimgffmpeg.cpp:369
369             if (avformat_open_input(&pFormatCtx, file, NULL, NULL))
(gdb) p pFormatCtx
$1 = (AVFormatContext *) 0x7fffffffe104
(gdb) p *pFormatCtx
$2 = {av_class = 0x7fff, iformat = 0x0, oformat = 0xf777f76d00000000,
  priv_data = 0x7fff, pb = 0xffffe1f800000000, nb_streams = 32767,
  streams = 0x40087400000003,
  filename = '\000' <repeats 12 times>"\201,
^̻\362\256?\342\220\a@\000\000\000\000\000\360\341\377\377\377\177",
'\000' <repeats 18 times>"\201,
^\214y\rQ\300\035\201^\234U\035@\300\035\000\000\000\000\377\177",
'\000' <repeats 18 times>"\360,
\n@\000\000\000\000\000\370\341\377\377\377\177\000\000\003", '\000'
<repeats 23 times>"\220,
\a@\000\000\000\000\000\360\341\377\377\377\177\000\000\000\000\000\000\000\000\000\000\271\a@\000\000\000\000\000\350\341\377\377\377\177\000\000\034\000\000\000\000\000\000\000\003\000\000\000\000\000\000\000\277\344\377\377\377\177\000\000\361\344\377\377\377\177\000\000\016\345\377\377\377\177\000\000\000\000\000\000\000\000\000\000+\345\377\377\377\177\000\000>\345\377\377\377\177\000\000i\345\377\377\377\177\000\000y\345\377\377\377\177\000\000\204\345\377\377\377\177\000\000\324\345\377\377\377\177\000\000\346\345\377\377\377\177\000\000\020\346\377\377\377\177\000\000\030\346\377\377\377\177\000\000\071\353\377\377\377\177\000\000s\353\377\377\377\177\000\000\247\353\377\377\377\177\000\000\315\353\377\377\377\177\000\000\b\354\377\377\377\177\000\000\\\354\377\377\377\177\000\000g\354\377\377\377\177\000\000\234\354\377\377\377\177\000\000\273"...,
timestamp = 5134489810073223222, ctx_flags = 1599360581,
  packet_buffer = 0x656b2f706d742f3d, start_time = 7735545232219533945,
  duration = 7453570836073628473, file_size = 4992331447231197242,
  bit_rate = 792546380, cur_st = 0x5245540068736162,
  data_offset = 30806552532761933, mux_rate = 1598506072,
  packet_size = 1397966163, preload = 1598967625, max_delay = 1263488835,
  loop_output = 909985097, flags = 1700934369, loop_input = 962880356,
  probesize = 1650811699, max_analyze_duration = 845559347,
  key = 0x3030303030383232 <Address 0x3030303030383232 out of bounds>,
  keylen = 758394928, nb_programs = 959787825, programs = 0x342e393935353734,
  video_codec_id = 959788088, audio_codec_id = 808660280,
  subtitle_codec_id = 842543925, max_index_size = 3485747,
  max_picture_buffer = 1145981271, nb_chapters = 1145657167,
  chapters = 0x373330353737333d, debug = 1313275957,
  raw_packet_buffer = 0x5f474e495259454b,
  raw_packet_buffer_end = 0x3d4c4f52544e4f43,
  packet_buffer_end = 0x79656b2f706d742f, metadata = 0x396b5a2d676e6972,
  raw_packet_buffer_remaining_size = 4743491,
  start_time_realtime = 4854690509218013757, fps_probe_size = 1380928591,
  error_recognition = 1936866643, interrupt_callback = {
    callback = 0x31303d69643a303d, opaque = 0x303d6e6c3a34333b}}

I amateurishly fixed that using

--- pHash-0.9.5/src/cimgffmpeg.cpp      2012-11-23 21:58:01.000000000 +0100
+++ pHash-0.9.5-m/src/cimgffmpeg.cpp    2013-01-27 11:12:53.454519885 +0100
@@ -362,10 +363,13 @@
 long GetNumberVideoFrames(const char *file)
 {
     long nb_frames = 0L;
-       AVFormatContext *pFormatCtx;
+       AVFormatContext *pFormatCtx = NULL;

@@ -404,11 +417,45 @@
                return nb_frames;
        }
 }
-
 float fps(const char *filename)
 {
         float result = 0;
-       AVFormatContext *pFormatCtx;
+       AVFormatContext *pFormatCtx = NULL;



------------------


Now i wanted to try this out, but it can't index most of my videos
because it's unable to get the number of frames.


------
bf at z:~/pHash-0.9.5-m$ ./examples/.libs/lt-test_video
/dev/shm/fa/test-video-{a.mp4,b.mkv}
file1=/dev/shm/fa/test-video-a.mp4
length 1
hash1[0]=4c38b3e34c8cb373
file=/dev/shm/fa/test-video-b.mkv
hash 2 is null
------

If you could walk me trough ph_getKeyFramesFromVideo i can try to fix
the not-working method of how it currently tries to get this number
(because if I got that correctly it should work without knowing this
number in advance) but I don't get what you do with the histograms. Is
that some kind of decision process which image is "important" or
"significant"?

And if it's not a secret... i don't get how it works :)
once you decided which frames are keyFrames you blur it, do a dct, get
the upper-left-most 64 pixels (that's the lower-frequency ones?),
throw them in an array, take the median and compare each of the values
to the median.
So it looks at the amplitudes of 64 frequencies and stores which of
these is above/below the median?
Is there some laymans guide of how one has to imagine fft-ed
greater-than-median bitstrings?

Did you play around with haar-wavelets and is there some hashing
method using that?

Thx in advance
  Beni.


More information about the pHash-support mailing list