{"action":"opened","issue":{"url":"https://api.github.com/repos/thaytan/gst-rpicamsrc/issues/46","labels_url":"https://api.github.com/repos/thaytan/gst-rpicamsrc/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/thaytan/gst-rpicamsrc/issues/46/comments","events_url":"https://api.github.com/repos/thaytan/gst-rpicamsrc/issues/46/events","html_url":"https://github.com/thaytan/gst-rpicamsrc/issues/46","id":129377758,"number":46,"title":"requesting an intra frame while recording","user":{"login":"chetanbnaik","id":7589914,"avatar_url":"https://avatars.githubusercontent.com/u/7589914?v=3","gravatar_id":"","url":"https://api.github.com/users/chetanbnaik","html_url":"https://github.com/chetanbnaik","followers_url":"https://api.github.com/users/chetanbnaik/followers","following_url":"https://api.github.com/users/chetanbnaik/following{/other_user}","gists_url":"https://api.github.com/users/chetanbnaik/gists{/gist_id}","starred_url":"https://api.github.com/users/chetanbnaik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chetanbnaik/subscriptions","organizations_url":"https://api.github.com/users/chetanbnaik/orgs","repos_url":"https://api.github.com/users/chetanbnaik/repos","events_url":"https://api.github.com/users/chetanbnaik/events{/privacy}","received_events_url":"https://api.github.com/users/chetanbnaik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-28T08:30:23Z","updated_at":"2016-01-28T08:30:23Z","closed_at":null,"body":"Hello thaytan,\r\n\r\nAs an alternative, I am trying to wrap the python picamera module with gstreamer pipeline using the appsrc element. \r\n\r\nin picamera module, I can redirect the stream to a custom output that must have a \"write\" method.\r\n```\r\nclass CamStreamer(object):\r\n    def __init__(self,videoFormat,resolution,framerate):\r\n        self.size = 0\r\n        self.capstring = 'video/x-'+videoFormat+',width='+str(resolution[0]) \\\r\n                         +',height='+str(resolution[1])+',framerate=' \\\r\n                         +str(framerate)+'/1'\r\n        self.playing = False\r\n        self.paused = False\r\n        self.make_pipeline()\r\n        self.play_pipeline()\r\n\r\n    def make_pipeline(self):\r\n        CLI = [\r\n                  'appsrc name=\"source\" ! ',\r\n                  'h264parse ! video/x-h264,stream-format=avc ! ',\r\n                  'h264parse ! video/x-h264,stream-format=byte-stream ! ',\r\n                  'mpegtsmux ! filesink name=\"sink\"'\r\n                  ]\r\n        gcmd = \"\".join(CLI)\r\n        self.pipeline = Gst.parse_launch(gcmd)\r\n        self.filesink = self.pipeline.get_by_name(\"sink\")\r\n        self.filesink.set_property(\"location\",\"custom.ts\")\r\n        self.appsrc = self.pipeline.get_by_name(\"source\")\r\n        self.appsrc.set_property(\"is-live\",True)\r\n        self.gstcaps = Gst.Caps.from_string(self.capstring)\r\n        self.appsrc.set_property(\"caps\",self.gstcaps)\r\n\r\n    def play_pipeline(self):\r\n        self.pipeline.set_state(Gst.State.PLAYING)\r\n\r\n    def stop_pipeline(self):\r\n        self.pipeline.set_state(Gst.State.READY)\r\n               \r\n    def write(self,s):\r\n        gstbuff = Gst.Buffer.new_wrapped(s)\r\n        ret = self.appsrc.emit(\"push-buffer\",gstbuff)\r\n\r\n    def flush(self):\r\n        self.stop_pipeline()\r\n```\r\nand then I use the camera object as below:\r\n```\r\nclass RPiCam(object):\r\n    def __init__(self):\r\n        self.resolution = (640,480)\r\n        self.bitrate = 1000000\r\n        self.format = \"h264\"\r\n        self.framerate = 30\r\n        self.rotation = 180\r\n        \r\n        self.camera = picamera.PiCamera()\r\n        self.camera.resolution = self.resolution\r\n        self.camera.framerate = self.framerate\r\n\r\n    def startCam(self):\r\n        self.camera.start_recording(CamStreamer(self.format,self.resolution,\r\n                                                     self.framerate),format=self.format, bitrate=self.bitrate)\r\n\r\n    def recordCam(self,duration):\r\n        self.camera.wait_recording(duration)\r\n\r\n    def stopCam(self):\r\n        self.camera.stop_recording()\r\n\r\n    def closeCam(self):\r\n        self.camera.close()\r\n\r\n```\r\n\r\nI wish to request an i frame while the recording is in progress. I see the following lines of code in RaspiCapture.c which give me some hints on how to request a key frame against an external event. Can you help me how to implement this using python?\r\n\r\n```\r\ngboolean raspi_capture_request_i_frame(RASPIVID_STATE *state)\r\n{\r\n   MMAL_PORT_T *encoder_output = NULL;\r\n   MMAL_STATUS_T status;\r\n   MMAL_PARAMETER_BOOLEAN_T param = {{  MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME, sizeof(param)}, 1};\r\n   encoder_output = state->encoder_component->output[0];\r\n   status = mmal_port_parameter_set(encoder_output, &param.hdr);\r\n   if (status != MMAL_SUCCESS)\r\n   {\r\n      vcos_log_error(\"Unable to request I-frame\");\r\n      return FALSE;\r\n   }\r\n   return TRUE;\r\n}\r\n```\r\n\r\nThanks!\r\n\r\n"}}