zoukankan      html  css  js  c++  java
  • 视频运动motion vector获取。

    http://victor.csie.org/blog/archives/362
    ----------------------------------------------------------------------
    Motion Vector Extraction June 10

    Filed under Uncategorized by victor | 1 comment

    為了做 MULTIMEDIA ANALYSIS AND INDEXING 這門課的 project,我們這組需要從 MPEG video 裡面取出 motion vector(它在 MPEG video 裡的用途是用來做壓縮。一個物體在畫面裡面移動時,其實只需要描述它的位移,而不需整個重新 encode)。

    不知道是不是因為大部分的人需要的都是 video 的 frame,而不是 motion vector(其實在解壓縮時只差一步),我 google 了好久都找不到工具可以用。後來發現 ffmpeg 的 ffplay 可以直接把 motion vector 邊撥邊畫出來,但是還是沒辦法 dump 出來。

    $ ffplay -vismv 3 xxx.mpg

    vismv 那個參數其實是三個 bit,第一個 bit 代表 P-Frame,第二個代表 B-Frame 的 forward motion vector,第三個 bit 則是 B-Frame 的 backward vector。

    不過,這只能看。所以我參考 Using libavformat and libavcodec 跟 ffplay 的 source code 寫了一個程式。這個程式可以把 video 每個 frame (除了沒有 motion vector 的 I-Frame)的 motion vector 取出來。如果要改成取第幾個 frame、或是某個 range 之類的,也很好改。

    g++ compile 時需要加上 -lavcodec -lavformat 兩個參數,當然也要先裝上 libavcodec 跟 libavformat 兩個 library。有裝 ffmpeg 就會有。

    http://victor.csie.org/archive/motion_vector.cpp


    ------------------------------------------------------------------------
    /usr/local/include/libavutil/common.h: In function 'int32_t av_clipl_int32_c(int64_t)':
    /usr/local/include/libavutil/common.h:168: error: 'UINT64_C' was not declared in this scope
    ----------------
    vi /usr/local/include/libavutil/common.h

    #ifdef __cplusplus
     #define __STDC_CONSTANT_MACROS
     #ifdef _STDINT_H
      #undef _STDINT_H
     #endif
     # include <stdint.h>
    #endif

    ----------------------
    在包含 ffmpeg 的相关头文件
    extern "C"
    {
    #include"filename.h"
    }

    转自:http://blog.chinaunix.net/uid-14779297-id-1988335.html

  • 相关阅读:
    WC命令
    dcoker machine
    linux命令
    Valgrind 检测程序内存使用
    golang flag
    面试之---二叉树的遍历
    FFMpeg 版本错误
    C++中namespace的使用
    QT之QStatusBar
    建立ftp服务器和客户端
  • 原文地址:https://www.cnblogs.com/retrieval/p/3180436.html
Copyright © 2011-2022 走看看