add support for files with no video (i.e. audio files)
fix stream selection (now in line with ffmpeg's logic) enlarge progress bars :-)
This commit is contained in:
parent
5de735234d
commit
09483b6c7c
1 changed files with 27 additions and 19 deletions
|
@ -155,7 +155,7 @@ if __name__ == '__main__':
|
|||
amount_vs = len(video_streams)
|
||||
amount_as = len(audio_streams)
|
||||
|
||||
if amount_vs != 1:
|
||||
if amount_vs > 1:
|
||||
main.print('detected §r%d§/ video streams' %(amount_vs), prefix.fail)
|
||||
print(video_streams)
|
||||
main.exit(1)
|
||||
|
@ -163,8 +163,10 @@ if __name__ == '__main__':
|
|||
if amount_as > 1:
|
||||
main.print('detected §y%d§/ audio streams, picking the "best" one (see man 1 ffmpeg, section STREAM SELECTION)' %(amount_as), prefix.warn)
|
||||
|
||||
if video_streams:
|
||||
# ffmpeg picks the stream with the highest pixel count and then the lowest index
|
||||
video_streams.sort(key=lambda s: s['width'] * s['height'], reverse=True)
|
||||
video = video_streams[0]
|
||||
|
||||
info.video_codec = video['codec_name']
|
||||
info.video_size_x = video['width']
|
||||
info.video_size_y = video['height']
|
||||
|
@ -177,8 +179,12 @@ if __name__ == '__main__':
|
|||
else:
|
||||
info.video_bitrate = '§r??§/'
|
||||
info.pixel_fmt = video['pix_fmt']
|
||||
else:
|
||||
info.video_fps = 30 # faked for progress bars
|
||||
|
||||
if audio_streams:
|
||||
# ffmpeg picks the stream with the most channels and then the lowest index
|
||||
audio_streams.sort(key=lambda s: s['channels'], reverse=True)
|
||||
audio = audio_streams[0]
|
||||
info.audio_codec = audio['codec_name']
|
||||
info.audio_channels = audio['channels']
|
||||
|
@ -191,8 +197,10 @@ if __name__ == '__main__':
|
|||
print(identify_dict)
|
||||
raise
|
||||
|
||||
# TODO wordify :-)
|
||||
if video_streams:
|
||||
main.print('§mvideo§/: size=§b%d§/x§b%d§/ px, framerate=%s, codec=%s, bitrate=%s' %(info.video_size_x, info.video_size_y, info.video_fps, info.video_codec, info.video_bitrate))
|
||||
else:
|
||||
main.print('§mvideo§/: §yNone§/', prefix.warn)
|
||||
|
||||
if audio_streams:
|
||||
main.print('§caudio§/: channels=§b%d§/, samplerate=%s, codec=%s, bitrate=%s, language=%s' %(info.audio_channels, info.audio_samplerate, info.audio_codec, info.audio_bitrate, info.audio_language))
|
||||
|
@ -210,7 +218,7 @@ if __name__ == '__main__':
|
|||
command.normalize_prepass.INFILE = 'file:' + str(files.infile)
|
||||
command.normalize_prepass.run(stderr=True)
|
||||
|
||||
pb = over.core.text.ProgressBar(60, int(info.video_fps.value * info.duration), 'frames')
|
||||
pb = over.core.text.ProgressBar(120, info.duration, 's')
|
||||
|
||||
output_buffer = []
|
||||
|
||||
|
@ -224,7 +232,7 @@ if __name__ == '__main__':
|
|||
|
||||
if b'frame=' in out:
|
||||
frame_id = re.findall(b'frame= *(\d+) ', out)[0]
|
||||
pb.update(int(frame_id))
|
||||
pb.update(int(frame_id) / info.video_fps.value)
|
||||
|
||||
elif out is None:
|
||||
break
|
||||
|
@ -331,7 +339,7 @@ if __name__ == '__main__':
|
|||
main.print('will encode into §B%s§/' %(files.tmpfile))
|
||||
|
||||
if main.cfg.armed:
|
||||
pb = over.core.text.ProgressBar(60, int(info.video_fps.value * info.duration), 'frames')
|
||||
pb = over.core.text.ProgressBar(120, int(info.video_fps.value * info.duration), 'frames')
|
||||
|
||||
encode_cmd.run(stderr=True)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue