timestamp in dv file, dvgrab oddness

Carl Karsten <[email protected]> Wed, 19 Aug 2009 13:54:55 -0500
Newsgroups gmane.comp.video.kino.devel
Message-ID <[email protected]>
I want to set the os file datetime to the datetime of the first frame
of the dv file.  I tired to figure out how to parse the dv frame, but
failed.  dvgrab will do it for me, but over 1/2 the time it 'hangs'
such that I need to kill-9 it (even when running the same command at a
shell prompt.)

The dvdate.py below seems to work, but the die die die stuff bothers
me, and it's kinda clunky anyway.

1. how else can I get the timestamp out of a .dv file?
Ideally I would like python bindings to some lib that will raise
exceptions if the format isn't right, etc.

2. why is dvgrab getting hung up?

3. not a huge deal, but...  my code creates /tmp/dvgNNN.dv files.  I
am guessing I can send that to /dev/null, or stdout.  any suggestions?
 I stopped trying things because it was hard to figure out if I was
making it hang up more.

#!/usr/bin/python

# dvdate.py - gets date of .dv file - shells out to dvgrab

import os, subprocess
import time
from dateutil.parser import parse

dvfile = 'pyohio.dv'

while True:
    p = subprocess.Popen( ['dvgrab', '-d', '1', '-I', dvfile,
'/tmp/dvg'], stderr=subprocess.PIPE )
    time.sleep(1)
    if p.poll() is None:
        print "die!"
        # p.send_signal()
        p.kill()
        print "dead?"
    else:
        out,err = p.communicate()
        break

text = err.split('\n')
if len(text)!=6: raise
dt=text[2].split()[-2:]
dt="%s %s" % tuple(dt)
# prolly use:
# datetime.strptime(date_string, format)
dt=parse(dt)
print dt

ts = time.mktime(dt.timetuple())

# os.utime(path, times) Set the access and modified
os.utime(dvfile,(ts,ts))



carl@gw42:~/Videos/pyohio-dupes/Cavern$ ./dvdate.py
die!
dead?
die!
dead?
die!
dead?
die!
dead?
die!
dead?
die!
dead?
die!
dead?
die!
dead?
die!
dead?
2009-07-25 10:04:34
carl@gw42:~/Videos/pyohio-dupes/Cavern$ ls -l pyohio.dv
-rw-r--r-- 1 carl carl 307200000 2009-07-25 10:04 pyohio.dv


-- 
Carl K

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july