我已經建立了我的系統與最新的ffmpeg和pHash庫(ffmpeg-2.2.1和pHash-0.9.6)以及pHash紅寶石寶石(https://github.com/toy/pHash)。當試圖比較兩個視頻與pHash庫和它的紅寶石綁定時的分割錯誤錯誤
我使用的紅寶石,並試圖比較兩個視頻文件是這樣的:
require 'phash/video'
video1 = Phash::Video.new('video1.mp4')
video2 = Phash::Video.new('video2.mp4')
video1 % video2
執行在分段故障該腳本的結果:
..../gems/pHash-1.1.4/lib/phash/video.rb:20: [BUG] Segmentation fault
ruby 1.9.3p545 (2014-02-24 revision 45159) [x86_64-darwin13.1.0]
-- Control frame information -----------------------------------------------
c:0008 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC :ph_dct_videohash
c:0007 p:0042 s:0024 b:0024 l:000023 d:000023 METHOD .../gems/pHash-1.1.4/lib/phash/video.rb:20
c:0006 p:0038 s:0017 b:0017 l:000016 d:000016 METHOD .../gems/pHash-1.1.4/lib/phash.rb:43
c:0005 p:0025 s:0014 b:0014 l:000013 d:000013 METHOD .../gems/pHash-1.1.4/lib/phash.rb:39
c:0004 p:0011 s:0011 b:0011 l:000010 d:000010 METHOD .../gems/pHash-1.1.4/lib/phash.rb:48
c:0003 p:0050 s:0006 b:0006 l:000128 d:0011b8 EVAL video_test_phash.rb:3
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000128 d:000128 TOP
-- Ruby level backtrace information ----------------------------------------
video_test_phash.rb:3:in `<main>'
.../gems/pHash-1.1.4/lib/phash.rb:48:in `similarity'
.../gems/pHash-1.1.4/lib/phash.rb:39:in `phash'
.../gems/pHash-1.1.4/lib/phash.rb:43:in `compute_phash'
.../gems/pHash-1.1.4/lib/phash/video.rb:20:in `video_hash'
.../gems/pHash-1.1.4/lib/phash/video.rb:20:in `ph_dct_videohash'
...
Abort trap: 6
看來,碰撞發生在ph_dct_videohash功能是pHash庫的一部分。該函數在文件pHash.cpp中。我在這裏複製它,以防它對某人有意義:
ulong64* ph_dct_videohash(const char *filename, int &Length){
CImgList<uint8_t> *keyframes = ph_getKeyFramesFromVideo(filename);
if (keyframes == NULL)
return NULL;
Length = keyframes->size();
ulong64 *hash = (ulong64*)malloc(sizeof(ulong64)*Length);
CImg<float> *C = ph_dct_matrix(32);
CImg<float> Ctransp = C->get_transpose();
CImg<float> dctImage;
CImg<float> subsec;
CImg<uint8_t> currentframe;
for (unsigned int i=0;i < keyframes->size(); i++){
currentframe = keyframes->at(i);
currentframe.blur(1.0);
dctImage = (*C)*(currentframe)*Ctransp;
subsec = dctImage.crop(1,1,8,8).unroll('x');
float med = subsec.median();
hash[i] = 0x0000000000000000;
ulong64 one = 0x0000000000000001;
for (int j=0;j<64;j++){
if (subsec(j) > med)
hash[i] |= one;
one = one << 1;
}
}
keyframes->clear();
delete keyframes;
keyframes = NULL;
delete C;
C = NULL;
return hash;
}
任何幫助非常感謝!
FFMPEG是否正確播放單個視頻? –
是的,我可以使用FFPLAY成功播放視頻,而且我也可以使用FFMPEG將視頻轉碼爲不同格式的視頻。 – anado1771