簡體   English   中英

跳過和/或丟失了編碼為H264視頻的編碼圖像嗎?

[英]Encoded images into H264 video are skipped and/or missing?

我正在嘗試將圖像編碼為H264 MP4視頻。 我遇到的問題是某些圖像被跳過了,或者在視頻末尾完全丟失了。 我需要視頻播放我編碼的每個圖像,因為它是動畫。

正確設置編碼器的任何幫助將不勝感激!

編碼器設置:

AVCodecContext *c;
...
c->codec_id = AV_CODEC_ID_H264;
c->bit_rate = mOutputWidth*mOutputHeight*4;//400000;
/* Resolution must be a multiple of two. */
c->width    = mOutputWidth;
c->height   = mOutputHeight;
    /* timebase: This is the fundamental unit of time (in seconds) in terms
     * of which frame timestamps are represented. For fixed-fps content,
     * timebase should be 1/framerate and timestamp increments should be
     * identical to 1. */
c->time_base.den = mFps;
c->time_base.num = 1;
c->gop_size      = 12; /* emit one intra frame every twelve frames at most */
c->pix_fmt       = AV_PIX_FMT_YUV420P;
...
av_dict_set(&pOptions, "preset", "medium", 0);
av_dict_set(&pOptions, "tune", "animation", 0);

/* open the codec */
ret = avcodec_open2(c, codec, &pOptions);
if (ret < 0) {
    LOGE("Could not open video codec: %s", av_err2str(ret));
    return -1;
}

更新13年7月24日:
通過設置gop_size=FPS並重復寫入最后一個視頻幀FPS+1次,我似乎可以解決所有問題,從而獲得更好的視頻。 對我來說,這樣做似乎很奇怪,但是在視頻編碼領域可能是標准的東西嗎? 關於此的任何提示反饋嗎?

據我了解,您有一組圖像,並且想要用它們制作視頻。 如果是這種情況,並且您不關心視頻的大小,則可以嘗試禁用幀間預測。 也許編碼器發現某些圖像不是必需的,並跳過了它們。

可以通過將gop_size設置為0來禁用幀間預測。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM