How to extract frames and saving frame type to filenames with ffmpeg?
Can't comment on the soundness of your theory, but here's a way to do it. Not directly, but in a roundabout way.

FFmpeg's segment muxer can break up a file at GOP boundaries, so running the command below generates a set of videos which each start with a keyframe but contain no other keyframes.

ffmpeg -i test.mp4 -c copy -f segment -segment_time 0.001 -segment_list list.ffcat -reset_timestamps 1 segs%d.mp4


This will create

segs0.mp4
segs1.mp4
...
segs101.mp4
..etc


Extract each segment to images

ffmpeg -i segN.mp4 outN-%d.png


Apply A on first frame of each image series and B on the rest.

Then for each processed series, run

ffmpeg -framerate X -i procN-%d.png -c:v libx264 -keyint_min 1000 -x264opts stitchable "result\segsN.mp4"


-keyint_min value should be greater than no. of frames in each series.

Hopefully the names of the resulting MP4s are the same as the original split segments, which makes the next step more convenient.

Copy the list.ffcat created in the initial segmenting command to the results folder and run

ffmpeg -f concat -safe 0 -i list.ffcat -c copy processed.mp4