The temporary uploaded video file does not appear in uploads directory 
until the video is completely uploaded. So is it possible to access the 
temporary video file when the file is being uploading ?Thanks!

On Friday, August 29, 2008 9:12:35 PM UTC+8, Massimo Di Pierro wrote:
>
> follow-up
>
> ---- convert.py ----
> import os, stat, time, logging
> while True:
>      files=[(os.stat(file)[stat.ST_CTIME],file) for file in os.listdir 
> (request.folder,'uploads') if file[:16]=='mytable.original']
>      files.sort()
>      if files:
>           file=files[-1]
>           original, converted=file,file.replace 
> ('.original.','.converted.')+'.flv'
>           try:
>              os.system('ffmpeg %s %s' % (original,converted))
>              db(db.mytable.original=original).update 
> (original='',converted=converted)
>              db.commit()
>           except:
>              os.unlink(original)
>              db(db.mytable.original=original).update(original='')
>              db.commit()
>              logging.error('unable to convert')
>      else: time.sleep(5)
> ----- end file----
>
> and run it in background with
>
>      nohup python web2py.py -S yourapp -R convert.py &
>
> Massimo
>
> On Aug 29, 2008, at 7:53 AM, Massimo Di Pierro wrote:
>
> >
> > Dear Mike,
> >
> > the conversion may take time and the server may kill the thread
> > before the conversion is done. By looking at youtube and how other
> > sites handle this, here is my suggestion. have two 'upload' fields:
> > original, converted. Default converted to ''. Write a batch web2py
> > script that runs in backrgound, looks for uploads/
> > yourtable.original.xxxxxxx.* files, sorts them by creating time,
> > converts each of them into uploads/yourtable.converted.xxxxxxx.flv
> > then updates the corresponding records by setting original to '' and
> > converted to 'yourtable.converted.xxxxxxx.flv'.
> >
> > Your interface can use ajax callbacks to query the database and check
> > is the record is completed by looking at the value of
> > yourtable.converted.
> >
> > Hope this helps.
> >
> > Massimo
> >
> > On Aug 29, 2008, at 5:52 AM, MikeHamer wrote:
> >
> >>
> >> Hey all,
> >> I'm an experienced low level (C/C++/ASM) programmer with very little
> >> experience in web programming and web frameworks, so please excuse my
> >> naivety.
> >>
> >> I've been working on a proof-of-concept site, testing out various
> >> frameworks and confirming that my idea is feasible. One of the
> >> features I am working on is video upload+playback.
> >>
> >> I've been quite impressed with web2py's upload streaming and  
> >> automatic
> >> renaming of uploaded files (among other features this has eased my
> >> entry into web-frameworks and web-programming). I would now like to
> >> extend (or enhance) this functionality and are looking for some
> >> suggestions as to the 'best practice' method of achieving this:
> >>
> >> Currently I have a video model:
> >> videos:
> >>     id (auto)
> >>     title (string)
> >>     videofile (upload)
> >>
> >> My goal is to:
> >> 1) Upload a video file (I would like to continue using SQLFORM if
> >> possible as this construct is fast and provides a whole load of
> >> functionality that I would prefer not to reimplement)
> >>
> >> 2) Validate that the uploaded file is a video file (read the metadata
> >> of the file object)
> >>
> >> 3) If the file is a video file
> >>             call ffmpeg (or equiv) to convert the file into a .flv
> >> file with set dimensions
> >> 3.1) else
> >>             return an error to the user
> >>
> >> 4) Record the new .flv file path into the videos.videofile (later to
> >> be played by the embedded flv player)
> >>
> >>
> >>
> >> My initial reaction was to use a custom validator (similar to CRYPT)
> >> to handle passing ffmpeg the input file and returning the
> >> cooresponding (ConvertedFilename.flv , None) tuple from the  
> >> vaildator.
> >> However consulting other validators that are designed to handle
> >> uploads (such as IS_LENGTH), it appears that the file is passed into
> >> the validator as a cgi.FieldStorage  (  if
> >> isinstance(value,cgi.FieldStorage)  ).
> >>
> >> ffmpeg only works with files (not binary data containers), so on that
> >> note I am stumped. It would be possible to write the  
> >> cgi.fieldstore to
> >> disk, then process it that way, however that would subvert web2py
> >> functionality rather than extending it.
> >>
> >>
> >>
> >> Any guidance would be appreciated,
> >> Mike
> >>
> >>>
> >
> >
> > >
>
>

Reply via email to