{"action":"created","issue":{"url":"https://api.github.com/repos/mikeboers/PyAV/issues/162","repository_url":"https://api.github.com/repos/mikeboers/PyAV","labels_url":"https://api.github.com/repos/mikeboers/PyAV/issues/162/labels{/name}","comments_url":"https://api.github.com/repos/mikeboers/PyAV/issues/162/comments","events_url":"https://api.github.com/repos/mikeboers/PyAV/issues/162/events","html_url":"https://github.com/mikeboers/PyAV/issues/162","id":146699414,"number":162,"title":"Question : Using PyAV in iPython, impossible to access all frames","user":{"login":"Celsius-J","id":18316026,"avatar_url":"https://avatars.githubusercontent.com/u/18316026?v=3","gravatar_id":"","url":"https://api.github.com/users/Celsius-J","html_url":"https://github.com/Celsius-J","followers_url":"https://api.github.com/users/Celsius-J/followers","following_url":"https://api.github.com/users/Celsius-J/following{/other_user}","gists_url":"https://api.github.com/users/Celsius-J/gists{/gist_id}","starred_url":"https://api.github.com/users/Celsius-J/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Celsius-J/subscriptions","organizations_url":"https://api.github.com/users/Celsius-J/orgs","repos_url":"https://api.github.com/users/Celsius-J/repos","events_url":"https://api.github.com/users/Celsius-J/events{/privacy}","received_events_url":"https://api.github.com/users/Celsius-J/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-07T17:55:46Z","updated_at":"2016-04-08T13:36:36Z","closed_at":"2016-04-08T13:36:36Z","body":"Hello,\r\n\r\nI am willing to use iPython to track the position of an object in a movie. To do so I use Video from the PIMS library: \r\n\r\n> frames = pims.Video('mass_4.MOV', as_grey=True)\r\n> frames\r\n\r\nAnd I get: \r\n\r\n> Out[19]: <Frames>\r\n> Source: mass_4.MOV\r\n> Length: 9657 frames\r\n> Frame Shape: 1280 x 720\r\n\r\nFor now everything works nice, and if I try to access to a frame from 0 to 24 it works, but if I try to access to another frame I get:\r\n\r\n> ---------------------------------------------------------------------------\r\n> AssertionError                            Traceback (most recent call last)\r\n> <ipython-input-49-38df71723696> in <module>()\r\n> ----> 1 frames[25]\r\n> \r\n> /Users/Jeff/anaconda/lib/python2.7/site-packages/pims/base_frames.pyc in __getitem__(self, key)\r\n>     161 \r\n>     162             # else, fall back to `get_frame`\r\n> --> 163             return self.get_frame(key if key >= 0 else _len + key)\r\n>     164 \r\n>     165     def __iter__(self):\r\n> \r\n> /Users/Jeff/anaconda/lib/python2.7/site-packages/pims/pyav_reader.pyc in get_frame(self, j)\r\n>     123         frame = self._current_packet[loc]  # av.VideoFrame\r\n>     124         if frame.index != j:\r\n> --> 125             raise AssertionError(\"Seeking failed to obtain the correct frame.\")\r\n>     126         result = np.asarray(frame.to_rgb().to_image())\r\n>     127         return Frame(self.process_func(result).astype(self._dtype), frame_no=j)\r\n> \r\n> AssertionError: Seeking failed to obtain the correct frame.\r\n\r\n\r\nDo you have an idea on where the problem come from please ?"},"comment":{"url":"https://api.github.com/repos/mikeboers/PyAV/issues/comments/207434457","html_url":"https://github.com/mikeboers/PyAV/issues/162#issuecomment-207434457","issue_url":"https://api.github.com/repos/mikeboers/PyAV/issues/162","id":207434457,"user":{"login":"mikeboers","id":130470,"avatar_url":"https://avatars.githubusercontent.com/u/130470?v=3","gravatar_id":"","url":"https://api.github.com/users/mikeboers","html_url":"https://github.com/mikeboers","followers_url":"https://api.github.com/users/mikeboers/followers","following_url":"https://api.github.com/users/mikeboers/following{/other_user}","gists_url":"https://api.github.com/users/mikeboers/gists{/gist_id}","starred_url":"https://api.github.com/users/mikeboers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikeboers/subscriptions","organizations_url":"https://api.github.com/users/mikeboers/orgs","repos_url":"https://api.github.com/users/mikeboers/repos","events_url":"https://api.github.com/users/mikeboers/events{/privacy}","received_events_url":"https://api.github.com/users/mikeboers/received_events","type":"User","site_admin":false},"created_at":"2016-04-08T13:36:36Z","updated_at":"2016-04-08T13:36:36Z","body":"`Frame.index` is roughly [`AVCodecContext.frame_number`](https://ffmpeg.org/doxygen/2.8/structAVCodecContext.html#a9e5a25a530d01c04491216c368a1a04a), which is the index of the frame as it was decoded, not any sort of frame counter within the stream.\r\n\r\nWithout digging into how `pims` actually works, I'm saying 95% it is a bad assumption on `pims`' part.\r\n\r\nThe reason the first 24 likely work is because FFmpeg reads some frames from the front to guess at the frame rate, and so they are established with indexes that match."}}