+ if c.find('AudioStream') is not None:
+ audio_channels = int(c.find('AudioStream').find('Mapping').find('InputChannels').text)
+ audio_frame_rate = int(c.find('AudioStream').find('FrameRate').text)
+ audio_length = int(c.find('AudioStream').find('Length').text)
+ names = { 1: 'mono', 2: 'stereo', 3: '3.0', 4: '4.0', 5: '4.1', 6: '5.1', 7: '6.1', 8: '7.1' }
+ os.system(f'ffmpeg -t {float(audio_length) / audio_frame_rate} -f lavfi -i anullsrc=channel_layout={names[audio_channels]}:sample_rate={audio_frame_rate} audio.aac')
+ if c.find('VideoFrameRate') is not None:
+ video_frame_rate = float(c.find('VideoFrameRate').text)
+ video_length = int(c.find('VideoLength').text)
+ video_cmd = '-s qcif -f rawvideo -pix_fmt rgb24 -r %f -i /dev/zero' % video_frame_rate
+ command(f'ffmpeg -t {video_length / video_frame_rate} -s qcif -f rawvideo -pix_fmt rgb24 -r {video_frame_rate} -i /dev/zero -shortest video.mp4')
+ if c.find('AudioStream') is not None and c.find('VideoFrameRate') is not None:
+ command(f'ffmpeg -i video.mp4 -i audio.aac -c copy -shortest "{path}"')
+ elif c.find('VideoFrameRate') is not None:
+ command(f'ffmpeg -i video.mp4 "{path}"')
+ else:
+ command('sox -n -r %d -c %d %s trim 0.0 %f' % (audio_frame_rate, audio_channels, path, float(audio_length) / audio_frame_rate))
+ try:
+ os.unlink('video.mp4')
+ os.unlink('audio.aac')
+ except:
+ pass
+ c.find('Path').text = path
+ c.find('Digest').text = digest_head_tail(path)
+ elif type == 'Image':
+ width = int(c.find('VideoWidth').text)
+ height = int(c.find('VideoHeight').text)
+ path = os.path.join(sys.argv[1], 'dummy', ntpath.basename(c.find('Path').text))
+ os.system('convert -size %dx%d xc:black "%s"' % (width, height, path))