{"action":"created","issue":{"url":"https://api.github.com/repos/NeuralEnsemble/ephyviewer/issues/10","repository_url":"https://api.github.com/repos/NeuralEnsemble/ephyviewer","labels_url":"https://api.github.com/repos/NeuralEnsemble/ephyviewer/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/NeuralEnsemble/ephyviewer/issues/10/comments","events_url":"https://api.github.com/repos/NeuralEnsemble/ephyviewer/issues/10/events","html_url":"https://github.com/NeuralEnsemble/ephyviewer/issues/10","id":348034766,"node_id":"MDU6SXNzdWUzNDgwMzQ3NjY=","number":10,"title":"Video playback performance and accuracy varies greatly between video files","user":{"login":"jpgill86","id":241234,"node_id":"MDQ6VXNlcjI0MTIzNA==","avatar_url":"https://avatars3.githubusercontent.com/u/241234?v=4","gravatar_id":"","url":"https://api.github.com/users/jpgill86","html_url":"https://github.com/jpgill86","followers_url":"https://api.github.com/users/jpgill86/followers","following_url":"https://api.github.com/users/jpgill86/following{/other_user}","gists_url":"https://api.github.com/users/jpgill86/gists{/gist_id}","starred_url":"https://api.github.com/users/jpgill86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpgill86/subscriptions","organizations_url":"https://api.github.com/users/jpgill86/orgs","repos_url":"https://api.github.com/users/jpgill86/repos","events_url":"https://api.github.com/users/jpgill86/events{/privacy}","received_events_url":"https://api.github.com/users/jpgill86/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-08-06T18:31:28Z","updated_at":"2018-08-07T20:55:49Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I'm finding that for some of my video files, ephyviewer's VideoViewer works great and can play video at any speed pretty well. However, I also have video files for which this is not true at all. For these files, the video playback feature is broken in bizarre ways. I have speculations on why some of my files are different from others, but I am very uncertain.\r\n\r\nMy videos were captured using two different video capture software: QuickTime on Mac and Logitech Webcam Software on Windows. The MOV video files produced by QuickTime _sometimes_ play well in ephyviewer, but not always. I haven't yet found an MP4 video file produced by the Logitech Webcam Software that does play well with ephyviewer.\r\n\r\nThe symptoms are rather strange. You can try it for yourself using this example, which includes two video clips with different video codecs exported from a much longer video captured using the Logitech software in MP4 format:\r\n\r\nhttps://files.mycloud.com/home.php?brand=webfiles&seuuid=89b32c3fb1da5c38c54dffd6b01334e8&name=ephyviewer-bad-video-playback-ex\r\n\r\nYou can change which of the two clips are loaded by changing one line in the Python script.\r\n\r\n_For the MPEG4-encoded clip, and for the original H264-encoded video from which both examples were clipped (original not included in example):_\r\n\r\nAfter pressing the play button, the video will play correctly for an interval of about 2 seconds before freezing on one frame. After a total of exactly 10 seconds have elapsed, the video will resume playing, jumping to the correct part of the video, but again it plays for only a 2 second interval. This pattern repeats every 10 seconds. The video resumes playback temporarily at times that are multiples of 10 seconds, even if playback was started in the middle of a decade (e.g., if the slider is dragged to t = 15 seconds before the play button is pressed, the video will remain on a frozen frame until time 20 seconds, at which point it will play for a short 2 second interval).\r\n\r\nIf the speed of playback is increased, this pattern does not seem to change at all. If the speed is decreased, the interval of successful playback may increase to perhaps 4 seconds (the amount seems to vary with the speed reduction factor and differs between the two computers I've tested this on), but there will still be a long period of no playback, and the cycle still repeats at multiples of 10 seconds.\r\n\r\n_For the H264-encoded clip, but NOT for the original H264-encoded video:_\r\n\r\n990 seconds of empty black frames are prepended to the video. Playback starts at t = 990 seconds. After that, an 8-second interruption pattern occurs, similar to the one described above. I did not create these clips starting from t = 990 seconds in the original video, so I have no idea where this number comes from.\r\n\r\nI've also seen other amounts of time prepended to _unclipped_ videos originally captured as MOV files in QuickTime. For example, I have an MOV video that is about 30 minutes 25 seconds long. When I load it in ephyviewer, the slider has a total length of 3825 seconds, which is exactly 2000 seconds too long. The video doesn't start until exactly t = 2000 seconds; before that it is just black. When the slider is positioned sometime after 2000 seconds, the video can be played correctly, _but this time without the periodic interruption pattern I've described_. In cases like this where the interruption pattern is absent and the shift in start time is the only anomaly, I can work around the problem by introducing a corrective time shift:\r\n\r\n    video_offset = -2000 # seconds\r\n    video_source.t_starts[0] += video_offset\r\n    video_source.t_stops[0]  += video_offset\r\n\r\nHowever, this is of course not ideal. The extra time is moved to the end, and, besides, in most cases the interruption pattern is present.\r\n\r\nI have hundreds of videos, so although I have dedicated many, many hours to trying to understand what's going on, I've only tested a handful of videos in that time! The symptoms might be even more varied than I'm reporting, and it's possible that the breakdown in playback performance has nothing to do with which video capture software I used.\r\n\r\nHowever, it still seems reasonable to expect that video format/encoding has something to do with the problem. I have spent hours using two different video conversion programs trying to find a way to fix playback for my videos which are not playing well with ephyviewer, but I haven't found a solution yet. In fact, I wanted to include in my example an excerpt from a video which works perfectly for comparison, but the software I'm using to cut my multi-gigabyte file down to a 40 second clip induces the irregular playback issue in the exported file.\r\n\r\nI am not very expert in video encoding formats, so I'm mostly guessing in the dark here (haha). I thought that perhaps this was an issue with PyAV's efficiency in playing certain compression formats, but then I noticed that both my original, uncut MOV and MP4 files -- some of which work flawlessly and others which do not -- use the same \"Codec: H264 - MPEG-4 AVC (part 10) (avc1)\" (according to VLC). Furthermore, of the two clips in my example, it's the one converted to \"Codec: MPEG-4 Video (mp4v)\" that actually works a little better. I'm not sure what actually makes some files work and others not. What's more, I'm not sure that odd behavior like the addition of hundreds of seconds of blank frames at the start of the video can be attributed solely to inefficient decoding algorithms!\r\n\r\nIf you can provide any insight into this problem, or if you know of a reliable format that works for you that I could convert my video files to, I would be incredibly grateful. ephyviewer is the perfect tool for the video and electrophys data analysis I want to do, and this video playback issue is the only thing holding me back right now!"},"comment":{"url":"https://api.github.com/repos/NeuralEnsemble/ephyviewer/issues/comments/411199514","html_url":"https://github.com/NeuralEnsemble/ephyviewer/issues/10#issuecomment-411199514","issue_url":"https://api.github.com/repos/NeuralEnsemble/ephyviewer/issues/10","id":411199514,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMTE5OTUxNA==","user":{"login":"samuelgarcia","id":815627,"node_id":"MDQ6VXNlcjgxNTYyNw==","avatar_url":"https://avatars1.githubusercontent.com/u/815627?v=4","gravatar_id":"","url":"https://api.github.com/users/samuelgarcia","html_url":"https://github.com/samuelgarcia","followers_url":"https://api.github.com/users/samuelgarcia/followers","following_url":"https://api.github.com/users/samuelgarcia/following{/other_user}","gists_url":"https://api.github.com/users/samuelgarcia/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelgarcia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelgarcia/subscriptions","organizations_url":"https://api.github.com/users/samuelgarcia/orgs","repos_url":"https://api.github.com/users/samuelgarcia/repos","events_url":"https://api.github.com/users/samuelgarcia/events{/privacy}","received_events_url":"https://api.github.com/users/samuelgarcia/received_events","type":"User","site_admin":false},"created_at":"2018-08-07T20:55:49Z","updated_at":"2018-08-07T20:55:49Z","author_association":"COLLABORATOR","body":"I finally found a much simpler solution.\r\n\r\nTry the latest comit on my repo and tell me if it is OK.\r\n"}}
{"actor":{"display_login":"samuelgarcia"}}