Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'output': 0.04; 'encoded': 0.05; 'intermediate': 0.05; 'modify': 0.05; 'processed': 0.05; '(especially': 0.07; 'chunk': 0.07; 'subject:file': 0.07; 'python': 0.09; 'chunks': 0.09; 'compute': 0.09; 'input,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'index': 0.13; 'frames': 0.16; 'frames.': 0.16; 'least,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:access': 0.16; 'subject:random': 0.16; 'tape': 0.16; 'tend': 0.17; 'appears': 0.18; 'changes': 0.20; 'followed': 0.20; 'constant': 0.22; 'expand': 0.26; 'possibly': 0.27; 'separate': 0.27; '(as': 0.27; 'streaming': 0.27; "doesn't": 0.28; 'header:X -Complaints-To:1': 0.28; 'definition': 0.29; 'starts': 0.29; '(and': 0.32; 'file': 0.32; 'loading': 0.33; 'url:home': 0.33; 'handle': 0.33; 'to:addr:python-list': 0.33; 'produced': 0.33; 'typically': 0.33; 'data,': 0.35; 'formats': 0.35; 'saved': 0.35; 'doing': 0.35; 'there': 0.35; 'received:org': 0.36; 'except': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.37; 'two': 0.37; 'uses': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'easily': 0.39; 'build': 0.39; 'hello,': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'most': 0.61; 'kind': 0.61; 'between': 0.63; 'series': 0.63; 'more': 0.63; 'video': 0.65; 'cameras': 0.84; 'computers.': 0.84; 'concept,': 0.84; 'vegas': 0.84; 'dennis': 0.91; 'received:108': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: random access to video file Date: Tue, 25 Sep 2012 12:28:43 -0400 Organization: > Bestiaria Support Staff < References: <743a4d43-286f-412e-9886-1cda4c8c5cb1@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-68-179-103.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348590526 news.xs4all.nl 6844 [2001:888:2000:d::a6]:52988 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30110 On Tue, 25 Sep 2012 01:51:43 -0700 (PDT), JRV declaimed the following in gmane.comp.python.general: > Hello, > > Is there a method for randomly accessing a video file in Python / OpenCV ? > > A kind of fseek which would allow to go directly to frame n ... > What format video file? Most are some variation of IFF chunked data, possibly interleaving the audio chunks with video image (especially in streaming formats -- whereas a fast drive might support having one video and one audio chunk, doing a lot of seeking between the two during playback). DV-AVI (as produced from standard definition miniDV tape cameras) have video encoded as a stream of JPEG frames. Since JPEG doesn't produce a constant output size for varying input, one can not just compute a "jump n-frames forward" except by having processed all the intermediate frames. MPEG (memory card/disk based standard definition cameras and HDV tape) uses a Group-of-Pictures concept, typically 15 frames to a GoP. A GoP consists of one JPEG frame at the beginning, followed by a series of changes from that frame (and those tend to have bidirectional change frames saved between them). To modify one frame typically requires regenerating the entire GoP. AVCHD is even more compressed than HDV MPEG -- and a 13GB (1-hour) HDV capture can easily expand to an 80GB "less-compressed" intermediate file for editing on slower computers. I suspect NLE software scans the video file during loading to build an index of, at the least, where each video chunk begins and what frame it starts on. With more memory, it may be possible to index by GoP. (Sony Vegas appears to handle the audio by building a separate proxy file of just the audio) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/