android - MediaCodec KEY_FRAME_RATE seems to be ignored -


i trying modify source screenrecord in android 4.4 , lower captured frame rate, no matter value put in:

format->setfloat("frame-rate", 5); 

the result same ( high frame rate )

is encoder ignoring property ? how can control frame rate ?

the frame-rate value not ignored, doesn't want.

the combination of frame-rate , i-frame-interval determines how i-frames (also called "sync frames") appear in encoded output. frame rate value might play role in meeting bitrate target on devices, i'm not sure (see e.g. this post).

the mediacodec encoder not drop frames. if want reduce frame rate, have sending fewer frames it.

the screenrecord command doesn't "sample" screen @ fixed frame rate. instead, every frame receives surface compositor (surfaceflinger) sent encoder, appropriate time stamp. if screenrecord receives 60 frames per seconds, you'll have 60fps output. if receives 10 frames in quick succession, followed nothing 5 seconds, followed couple more, you'll have in output file.

you can modify screenrecord drop frames, have bit careful. if try reduce maximum frame rate 60fps 30fps dropping every-other frame, run risk in "frame0 - frame1 - long_pause - frame2" sequence you'll drop frame1, , video hold on frame0 instead, showing not-quite-complete animation. need buffer frame, , encode or drop frame n-1 if difference in presentation times between , frame n ~17ms.

the tricky part screenrecord, in default operating mode, directs frames encoder without touching them, see encoded output. can't arbitrarily drop individual frames of encoded data, want prevent encoder seeing them in first place. if use screenrecord v1.1 sources can tap "overlay" mode, used --bugreport, have frames pass through screenrecord on way encoder.

in respects might simpler write post-processor reduces frame rate. don't know how quality lost decoding , re-encoding video.

update: example of how crudely, add processframe_l():

     int64_t droppedframes = 0; +    { +        static int flipflop = 0; +        flipflop = 1 - flipflop; +        if (flipflop) { +            printf("dropping frame %lld\n", framenumber); +            return; +        } +    }       if (mlastframenumber > 0) { 

note comes after updateteximage(), acquires next buffer, , skips call swapbuffers(), submits buffer video encoder.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -