Example #1
0
    def export(self, hashVal, hashPath, tags=None, galleries=None):
        '''
        The export function needs to:
        - Move source image to asset folder
        - Rename to guid.ext
        - Save thumbnail, video_thumbnail, and MP4 versions.  If the source is already h264, then only transcode the thumbnails
        '''

        self.source = hashPath.replace('\\', '/').replace(ROOT, '')
        galleries = galleries or []
        tags = tags or []

        ## -- Get info
        # ffprobe is the same as ffmpeg without output but it doesn't print a warning about missing the output file.
        # Note that FFMPEG prints nothing to stdout and all the info is on stderr
        ffprobe = os.path.join(settings.FFMPEG_BIN_DIR, 'ffprobe')
        cmd = '%s -i "%s"' % (ffprobe, hashPath)
        infoString = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
        videodata = videoThread.parseInfo(infoString.splitlines())
        
        self.width = int(videodata['video'][0]['width'])
        self.height = int(videodata['video'][0]['height'])

        ## -- Save thumbnail and put into queue
        thumbnail = hashPath.parent / ("_%s.jpg" % hashVal)
        # `-y` to overwrite without asking
        cmd = '%s -i "%s" -ss 1 -vframes 1 -y "%s"' % (
            settings.FFMPEG,
            hashPath,
            thumbnail
        )
        #proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        #proc.communicate()
        subprocess.check_call(cmd, shell=True)

        self.thumbnail = thumbnail.replace('\\', '/').replace(ROOT, '')

        for gal in galleries:
            g = Gallery.objects.get(pk=int(gal))
            g.videos.add(self)

        artistTag = Tag.objects.get_or_create(name=self.author.first_name + ' ' + self.author.last_name)[0]
        self.tags.add(artistTag)

        for tagName in tags:
            tag = Tag.objects.get_or_create(name=tagName)[0]
            self.tags.add(tag)

        if not self.guid:
            self.guid = self.getGuid().guid

        ## -- Set the temp video while processing
        self.video = videoThread.VIDEO_QUEUED
        queuedvideo = VideoQueue.objects.get_or_create(video=self)[0]
        queuedvideo.save()

        self.save()

        gQueue.put(self)
Example #2
0
    def export(self, hashVal, hashPath, tags=None, galleries=None):
        '''
        The export function needs to:
        - Move source image to asset folder
        - Rename to guid.ext
        - Save thumbnail, video_thumbnail, and MP4 versions.  If the source is already h264, then only transcode the thumbnails
        '''

        self.source = hashPath.replace('\\', '/').replace(ROOT, '')
        galleries = galleries or []
        tags = tags or []

        ## -- Get info
        cmd = '%s -v quiet -show_format -show_streams -print_format json "%s"' % (settings.FROG_FFPROBE, hashPath)
        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        infoString = proc.stdout.read()
        videodata = parseInfo(infoString)
        
        self.width = int(videodata['video']['width'])
        self.height = int(videodata['video']['height'])

        ## -- Save thumbnail and put into queue
        thumbnail = hashPath.parent / ("_%s.jpg" % hashVal)
        cmd = '%s -nostdin -i "%s" -ss 1 -vframes 1 "%s"' % (
            settings.FROG_FFMPEG,
            hashPath,
            thumbnail
        )
        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        thumbnailoutput = proc.communicate()

        self.thumbnail = thumbnail.replace('\\', '/').replace(ROOT, '')

        for gal in galleries:
            g = Gallery.objects.get(pk=int(gal))
            g.videos.add(self)


        artistTag = Tag.objects.get_or_create(name=self.author.first_name + ' ' + self.author.last_name)[0]
        self.tags.add(artistTag)

        for tagName in tags:
            tag = Tag.objects.get_or_create(name=tagName)[0]
            self.tags.add(tag)

        if not self.guid:
            self.guid = self.getGuid().guid

        ## -- Set the temp video while processing
        self.video = 'frog/i/queued.mp4'
        queuedvideo = VideoQueue.objects.get_or_create(video=self)[0]
        queuedvideo.save()

        self.save()

        gQueue.put(self)
Example #3
0
    def export(self, hashVal, hashPath, tags=None, galleries=None):
        '''
        The export function needs to:
        - Move source image to asset folder
        - Rename to guid.ext
        - Save thumbnail, video_thumbnail, and MP4 versions.  If the source is already h264, then only transcode the thumbnails
        '''

        self.source = hashPath.replace('\\', '/').replace(ROOT, '')
        galleries = galleries or []
        tags = tags or []

        ## -- Get info
        cmd = '%s -i "%s"' % (FROG_FFMPEG, hashPath)
        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        infoString = proc.stdout.readlines()
        videodata = parseInfo(infoString)
        
        self.width = int(videodata['video'][0]['width'])
        self.height = int(videodata['video'][0]['height'])

        ## -- Save thumbnail and put into queue
        thumbnail = hashPath.parent / ("_%s.jpg" % hashVal)
        cmd = '%s -i "%s" -ss 1 -vframes 1 "%s"' % (
            FROG_FFMPEG,
            hashPath,
            thumbnail
        )
        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        proc.communicate()

        self.thumbnail = thumbnail.replace('\\', '/').replace(ROOT, '')

        for gal in galleries:
            g = Gallery.objects.get(pk=int(gal))
            g.videos.add(self)

        artistTag = Tag.objects.get_or_create(name=self.author.first_name + ' ' + self.author.last_name)[0]
        self.tags.add(artistTag)

        for tagName in tags:
            tag = Tag.objects.get_or_create(name=tagName)[0]
            self.tags.add(tag)

        if not self.guid:
            self.guid = self.getGuid().guid

        ## -- Set the temp video while processing
        self.video = 'frog/i/queued.mp4'
        queuedvideo = VideoQueue.objects.get_or_create(video=self)[0]
        queuedvideo.save()

        self.save()

        gQueue.put(self)