當要求在非關鍵幀上拆分/複製時,ffmpeg是否可以計算新的起始關鍵幀?


2

我從問題here中了解到,關鍵幀可以(並且確實)發生在h.264流中的任何位置,所以我想知道為什麼大多數建議都是我看到用戶想要在特定時間或幀上剪切的(那不是關鍵幀),則如果他們要進行直接流複製,則必須轉到下一個/上一個關鍵幀並從那裡開始剪切

是否可以從任何幀中將ffmpeg剪切到任何位置,如果恰好是起始幀不是關鍵幀,然後返回最近的關鍵幀,然後繼續進行構成將被大量使用的新關鍵幀更接近用戶要從其開始的非關鍵幀?

例如,如果我們有規則,關鍵幀K之後必須跟隨以n開頭的任意數量的no模式,並且用戶希望剪切某些o

KnononononoKnononononoKnonononono
      ^                                 //and the user wants to cut on an o

    knononoKnononononoKnonononono       //use Knono to generate a new k, place it near the o
           '

然後僅對這個新關鍵幀加上原始非關鍵幀knonono進行編碼,然後從撇號上方的幀開始流複製?

第二個Knonononono的整個編碼是否依賴於第一個Knonononono的輸出,因此有連鎖效應/替換第一個塊會破壞流嗎?(如果是這樣的話,那麼在這方面削減現有關鍵幀有何幫助?)

0

In principle, this is possible, and is usually called "smart" encoding or rendering in the video editors / apps that offer this facility, typically in limited circumstances. FFmpeg does not have support for it.

The main complication is that the parameters of the encoded portion has to match the coding parameters of the existing stream. That is specific to each codec, and ffmpeg supports hundreds of video codecs. It would require significant redesign to parts of ffmpeg to have different handling for parts of an output stream, and to correctly parse the existng stream and ensure a compatible encoding. It's quite a bit of work and testing required for a feature that can be accomplished manually using a few more commands i.e. segmenting the input file, transcoding the changed /trimmed portions, and stitching the transcoded and old segments.