check if source has audio

This commit is contained in:
derchris 2020-01-13 12:53:14 +01:00
parent e38e77ecb9
commit 91f8807275

View file

@ -92,14 +92,15 @@ if not args.debug and not args.pause and not args.outro and not args.bgloop and
error("Either specify --debug, --pause, --outro or supply a schedule") error("Either specify --debug, --pause, --outro or supply a schedule")
if args.debug: if args.debug:
persons = ['watz'] persons = ['ln']
#persons = ['R. Rehak', 'julika', 'lislis', 'I. Hermann', 'E. Manifesti', 'joliyea', 'V. Schlüter', 'C. Haupt', 'K. Henneberger' , 'A. Höfner']
events = [{ events = [{
'id': 1, 'id': 133,
'title': 'Eröffnungsveranstaltung', 'title': 'Lithium-Ion Batteries: Why do they work?',
'subtitle': 'Easterhegg 2018', 'subtitle': '',
'persons': persons, 'persons': persons,
'personnames': ', '.join(persons), 'personnames': ', '.join(persons),
'room': 'Heisenberg 1', 'room': 'schaoswest',
}] }]
elif args.pause: elif args.pause:
@ -164,6 +165,12 @@ def run(command, **kwargs):
stdout=subprocess.DEVNULL) stdout=subprocess.DEVNULL)
def run_output(command, **kwargs):
return subprocess.check_output(
fmt_command(command, **kwargs),
stderr=subprocess.STDOUT)
def enqueue_job(event): def enqueue_job(event):
event_id = str(event['id']) event_id = str(event['id'])
if (os.path.exists(os.path.join(args.project, event_id + '.ts')) or os.path.exists(os.path.join(args.project, event_id + '.mov'))) and not args.force: if (os.path.exists(os.path.join(args.project, event_id + '.ts')) or os.path.exists(os.path.join(args.project, event_id + '.mov'))) and not args.force:
@ -234,15 +241,29 @@ def finalize_job(job_id, event):
final_clip = os.path.join(os.path.dirname(args.project), event_id + '.ts') final_clip = os.path.join(os.path.dirname(args.project), event_id + '.ts')
if args.alpha: if args.alpha:
run('ffmpeg -y -hide_banner -loglevel error -i {input} -map 0:0 -c:v qtrle -movflags faststart -aspect 16:9 -map 0:1 -c:a mp2 -b:a 384k -shortest -f mov {output}', ffprobe = run_output('ffprobe -i {input} -show_streams -select_streams a -loglevel error',
input=intermediate_clip, input=intermediate_clip)
output=final_clip) if ffprobe:
run('ffmpeg -y -hide_banner -loglevel error -i {input} -c:v qtrle -movflags faststart -aspect 16:9 -c:a mp2 -b:a 384k -shortest -f mov {output}',
input=intermediate_clip,
output=final_clip)
else:
run('ffmpeg -y -hide_banner -loglevel error -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -i {input} -c:v qtrle -movflags faststart -aspect 16:9 -c:a mp2 -b:a 384k -shortest -f mov {output}',
input=intermediate_clip,
output=final_clip)
else: else:
run('ffmpeg -y -hide_banner -loglevel error -i {input} -map 0:0 -c:v mpeg2video -q:v 2 -aspect 16:9 -map 0:1 -c:a mp2 -b:a 384k -shortest -f mpegts {output}', ffprobe = run_output('ffprobe -i {input} -show_streams -select_streams a -loglevel error',
#run('ffmpeg -y -hide_banner -loglevel error -i {input} -map 0:0 -c:v mpeg2video -q:v 2 -aspect 16:9 -map 1:0 -c:a mp2 -map 2:0 -c:a mp2 -shortest -f mpegts {output}', input=intermediate_clip)
#run('ffmpeg -y -hide_banner -loglevel error -i {input} -f lavfi -i anullsrc -ar 48000 -ac 2 -map 0:v -c:v mpeg2video -q:v 0 -aspect 16:9 -map 1:0 -c:a copy -map 2:0 -c:a copy -shortest -f mpegts {output}', if ffprobe:
input=intermediate_clip, event_print(event, "finalize with audio from source file")
output=final_clip) run('ffmpeg -y -hide_banner -loglevel error -i {input} -c:v mpeg2video -q:v 2 -aspect 16:9 -c:a mp2 -b:a 384k -shortest -f mpegts {output}',
input=intermediate_clip,
output=final_clip)
else:
event_print(event, "finalize with silent audio")
run('ffmpeg -y -hide_banner -loglevel error -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -i {input} -c:v mpeg2video -q:v 2 -aspect 16:9 -c:a mp2 -b:a 384k -shortest -f mpegts {output}',
input=intermediate_clip,
output=final_clip)
if event_id == 'pause' or event_id == 'outro' or event_id == 'bgloop': if event_id == 'pause' or event_id == 'outro' or event_id == 'bgloop':
event_print(event, "finalized " + str(event_id) + " to " + final_clip) event_print(event, "finalized " + str(event_id) + " to " + final_clip)