Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure about that, naively you could turn the entire cut GOP into i-frames couldn't you? I'm not super familiar with the nitty gritty of h264/h265 but intuitively I think you wouldn't even need to turn everything in the GOP into i-frames. You could trace out the inter-frame topology of the GOP and then replace only the "orphan" frames with i-frames, then the remaining p and b-frames would retain the necessary reference data for decoding.

I would love it if someone who knows more about this than I do would confirm/deny since this is something I've been curious about for a long time now. (Though I would also love a tool for near-lossless cutting that just re-encodes the cut GOP, please link such a thing if it exists)



"naively you could turn the entire cut GOP into i-frames couldn't you"

Yes, but then you'd have to render the result into a truly uncompressed format and it would have to stay in that format perpetually. If you wanted to deliver in another lossy format, you'd actually lose quality across the entire file instead of just the one GOP.

What I'm curious about is whether you can cut in the middle of GOPs, recompress the afflicted ones, and then concatenate the stream back together without recompressing all GOPs. If the file specifies a 12-frame GOP, cutting any GOPs is going to break that cadence. So can you have, say, a few thousand 12-frame GOPs... then an 8-frame GOP... then go back to 12-frame GOPs?

Update: Did some research and you can have "adaptive" GOPs of varying lengths: https://docs.aws.amazon.com/mediaconvert/latest/ug/gop-struc...


Yeah there's no issue there, most codecs support variable bitrates and variable iframe-pacing, and ffmpeg will happily concat such files. Also, there's no need to render into an "uncompressed format" the i-frames are still compressed, and even in the naive case you'd only need small number of i-frames because you only need to replace any orphans in the cut GOP after which you can just go back to normal decoding.


Yeah, you can absolutely reencode just the GOP where the cut happens and IIRC quite a few tools support that.


Indeed, was wondering whether there is a clever tool like that, i-frames is a simple idea, and then you could potentiality did something smarter like your tracing idea




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: