summaryrefslogtreecommitdiff
path: root/hacks
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-08-22 09:10:23 +0200
committerCarl Hetherington <cth@carlh.net>2022-08-22 09:10:23 +0200
commitaed4009b0a597d54d28202b4966d426fb8502534 (patch)
treef356ec7db607a65b32fd5a66d2fc5d645bc86338 /hacks
parent50bfbd85db2cd237060c304d269fabd9db551161 (diff)
Fix audio-only sources, and non-integer frame rates.
Diffstat (limited to 'hacks')
-rwxr-xr-xhacks/make_dummy_files13
1 files changed, 8 insertions, 5 deletions
diff --git a/hacks/make_dummy_files b/hacks/make_dummy_files
index 1370fff98..4cbc88d2d 100755
--- a/hacks/make_dummy_files
+++ b/hacks/make_dummy_files
@@ -110,16 +110,19 @@ for c in root.find('Playlist').findall('Content'):
video_cmd = ''
audio_cmd = ''
path = os.path.join(sys.argv[1], 'dummy', ntpath.basename(c.find('Path').text))
- 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 %d -i /dev/zero' % video_frame_rate
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' }
audio_cmd = '-f lavfi -i anullsrc=channel_layout=%s:sample_rate=%d' % (names[audio_channels], audio_frame_rate)
- os.system('ffmpeg -t %d %s %s -shortest "%s"' % (float(video_length) / video_frame_rate, video_cmd, audio_cmd, path))
+ 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
+ os.system('ffmpeg -t %f %s %s -shortest "%s"' % (video_length / video_frame_rate, video_cmd, audio_cmd, path))
+ else:
+ os.system('sox -n -r %d -c %d %s trim 0.0 %f' % (audio_frame_rate, audio_channels, path, float(audio_length) / audio_frame_rate))
c.find('Path').text = path
c.find('Digest').text = digest_head_tail(path)
elif type == 'Image':