2013-10-02 38 views
2

你好,我試圖編碼視頻使用C ffmpeg庫。出於某種原因,當我試圖創建一個格式方面,我得到一個錯誤:libavformat/ffmpeg c程序「不適合的輸入格式」

[NULL @ 0x7ff574006600] Requested output format 'mp4' is not a suitable output format

我知道我的ffmpeg的編譯與X264的標誌,作爲一個簡單的

ffmpeg -i test.mov test.mp4

工作正常。我也鏈接所有生成的pch文件,而libav *庫中的所有其他文件都工作正常。這裏是有錯誤的,我recieving一個完整的工作示例:

#include <libavformat/avformat.h> 
#include <libavcodec/avcodec.h> 
#include <libavutil/avutil.h> 
#include <libswscale/swscale.h> 
#include <libavutil/opt.h> 
#include <libswscale/swscale.h> 
#include <libavutil/imgutils.h> 

#include <stdio.h> 

int main() { 

    AVFormatContext * output = NULL; 

    // now lets initialize the actual format element 
    if (avformat_alloc_output_context2(&output, NULL, "mp4", "test.mp4") < 0) { 

     printf("%s", "INVALID"); 
    } 

    return 0; 

} 

回答

2

你必須調用分配輸出上下文

av_register_all(); 

之前。