Пример #1
0
def get_mp3_tags(file):
    from mp3_tagger import MP3File
    if util.get_file_extension(file).lower() != 'mp3':
        raise media.FileTypeError('File %s is not an mp3 file')
    # Create MP3File instance.
    mp3 = MP3File(file)
    return { 'artist' : mp3.artist, 'author' : mp3.artist, 'song' : mp3.song, 'title' : mp3.song, \
        'album' : mp3.album, 'year' : mp3.year, 'track' : mp3.track, 'genre' : mp3.genre, 'comment' : mp3.comment }
Пример #2
0
 def get_tags(self):
     """Returns all file MP3 tags"""
     from mp3_tagger import MP3File
     if util.get_file_extension(self.filename).lower() != 'mp3':
         raise media.FileTypeError('File %s is not an mp3 file')
         # Create MP3File instance.
     mp3 = MP3File(self.filename)
     self.artist = mp3.artist
     self.title = mp3.song
     self.album = mp3.album
     self.year = mp3.year
     self.track = mp3.track
     self.genre = mp3.genre
     self.comment = mp3.comment
Пример #3
0
def stack(file1, file2, direction, out_file = None):
    util.logger.debug("stack(%s, %s, %s, _)", file1, file2, direction)
    if not util.is_image_file(file1):
        raise media.FileTypeError('File %s is not an image file' % file1)
    if not util.is_image_file(file2):
        raise media.FileTypeError('File %s is not an image file' % file2)
    out_file = util.automatic_output_file_name(out_file, file1, "stacked")
    w1, h1 = ImageFile(file1).get_dimensions()
    w2, h2 = ImageFile(file2).get_dimensions()
    tmpfile1 = file1
    tmpfile2 = file2
    util.logger.debug("Images dimensions: %d x %d and %d x %d", w1, h1, w2, h2)
    if direction == 'horizontal':
        filter_name = 'hstack'
        if h1 > h2:
            new_w2 = w2 * h1 // h2
            tmpfile2 = rescale(file2, new_w2, h1)
        elif h2 > h1:
            new_w1 = w1 * h2 // h1
            tmpfile1 = rescale(file1, new_w1, h2)
    else:
        filter_name = 'vstack'
        if w1 > w2:
            new_h2 = h2 * w1 // w2
            tmpfile2 = rescale(file2, w1, new_h2)
        elif w2 > w1:
            new_h1 = h1 * w2 // w1
            tmpfile1 = rescale(file1, w2, new_h1)

    # ffmpeg -i a.jpg -i b.jpg -filter_complex hstack output

    util.run_ffmpeg('-i "%s" -i "%s" -filter_complex %s "%s"' % (tmpfile1, tmpfile2, filter_name, out_file))
    if tmpfile1 is not file1:
        util.delete_files(tmpfile1)
    if tmpfile2 is not file2:
        util.delete_files(tmpfile2)
    return out_file
Пример #4
0
    def __init__(self, filename):
        if not util.is_video_file(filename):
            raise media.FileTypeError(
                'File {0} is not a video file'.format(filename))

        self.aspect = None
        self.video_codec = None
        self.video_bitrate = None
        self.width = None
        self.height = None
        self.pixels = None
        self.duration = None
        self.video_fps = None
        self.pixel_aspect = None
        self.audio_bitrate = None
        self.audio_codec = None
        self.audio_language = None
        self.audio_sample_rate = None
        self.stream = None
        super(VideoFile, self).__init__(filename)
        self.get_specs()
Пример #5
0
all_props = list(set(VIDEO_PROPS + AUDIO_PROPS + IMAGE_PROPS))

if args.format == 'csv':
    print("# ")
    for prop in all_props:
        print("%s;" % prop, end='')
        if prop == 'duration':
            print("%s;" % "Duration HH:MM:SS", end='')
    print('')

props = all_props
nb_files = len(filelist)
for file in filelist:
    try:
        if not util.is_media_file(file):
            raise media.FileTypeError(
                "File %s is not a supported file format" % file)
        if util.is_video_file(file):
            file_object = video.VideoFile(file)
            if nb_files == 1:
                props = VIDEO_PROPS
        elif util.is_audio_file(file):
            file_object = audio.AudioFile(file)
            if nb_files == 1:
                props = AUDIO_PROPS
        elif util.is_image_file(file):
            file_object = img.ImageFile(file)
            if nb_files == 1:
                props = IMAGE_PROPS

        specs = file_object.get_properties()
        util.logger.debug("Specs = %s", util.json_fmt(specs))