Hello all,
I am trying to use ffmpeg+x265 for a somewhat unusual task. Given an encoded H.265 input, I would like to re-encode specific B-frames while maintaining the same List0/List1 reference pictures from the input. For example, given an input: I-P-B with the I frame in L0 and the P frame in L1 of the B-frame. I want to decode the input, optionally modify the B-frame’s uncompressed YUV representation and then re-encode it (and only it) as a B-frame using the I-frame as L0 and the P-frame as L1. I don’t want to re-encode both I- and P-frames because performance is of essence. I tried several approaches: 1. Try to use the ffmpeg command line options for concatenation and the copy codec (input encoded I/P and raw B). This, obviously, doesn’t work because codec copy doesn’t decode the input and you can’t reference an *encoded* frame… 2. Study the x265 encoder code to see how I can provide the List0/List1 reference frames as inputs and directly encode a B-frame with the given reference frames. After conducting a study, I reached file slicetype.cpp and specifically Lookahead::slicetypeDecide which uses pictures added through Lookahead::addPicture but I really got stuck there with locking issues because I don’t plan on encoding the I- and P-frames but on the other hand, they should be listed… 3. Another approach I tried briefly was to only remove the B-frame’s CABAC down to the encoded syntax elements (not to decode all the way to raw/YUV format), then change the residuals and re-apply the CABAC layer. Felt like a hack and I got terribly stuck with mapping the slice syntax elements from the ffmpeg h265 decoder (hevc.c etc…) to x265 encoder structures… In summary, I'm looking for any advice from experts on how you would try to implement this unorthodox task, especially based on approaches #2 (or #3) above. Clearly the x265 encoder does have the capability of encoding a B-frame given specific reference frames, but how do you suggest I isolate it? Any help, tips or suggestions will be greatly appreciated. Many thanks, Rachel
_______________________________________________ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel