all parts must have the streams in the same order

This commit is contained in:
j 2018-02-10 13:17:45 +01:00
parent 0708521a0f
commit b3df4b1a92
2 changed files with 9 additions and 4 deletions

View file

@ -198,7 +198,8 @@ if __name__ == '__main__':
stream_in = math.ceil(stream_in / (1/25)) * 1/25 stream_in = math.ceil(stream_in / (1/25)) * 1/25
stream_out = math.ceil(stream_out / (1/25)) * 1/25 stream_out = math.ceil(stream_out / (1/25)) * 1/25
info = get_info(api, clip['streams'][i], clip['item'], i+1) info = get_info(api, clip['streams'][i], clip['item'], i+1)
if stream_out > stream_in: clip_duration = stream_out - stream_in
if clip_duration > 0:
videos.append({ videos.append({
'oshash': clip['streams'][i], 'oshash': clip['streams'][i],
'url': '%s/%s/%sp%s.mp4' % (base_url, clip['item'], stream_resolution, i + 1), 'url': '%s/%s/%sp%s.mp4' % (base_url, clip['item'], stream_resolution, i + 1),

View file

@ -104,12 +104,14 @@ for clip in edit:
else: else:
files.append(out) files.append(out)
src_info = ox.avinfo(clip['path']) src_info = ox.avinfo(clip['path'])
vid = src_info['video'][0]['id']
if not src_info['audio']: if not src_info['audio']:
audio = ['-f', 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=48000'] audio = ['-f', 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=48000']
audio_map = [] audio_map = ['-map', '0,0', '-map', '1,1']
else: else:
aid = src_info['audio'][0]['id']
audio = [] audio = []
audio_map = ['-map', '0:0,0:0', '-map', '0:1,0:1'] audio_map = ['-map', '0:%s,0:0' % aid, '-map', '0:%s,0:1' % vid]
cmd = [ cmd = [
'ffmpeg', 'ffmpeg',
'-nostats', '-loglevel', 'error', '-nostats', '-loglevel', 'error',
@ -145,6 +147,7 @@ with open(txt, 'w') as fd:
cmd = ['ffmpeg', cmd = ['ffmpeg',
'-nostats', '-loglevel', 'error', '-nostats', '-loglevel', 'error',
'-y', '-f', 'concat', '-safe', '0', '-i', txt, '-c', 'copy', output] '-y', '-f', 'concat', '-safe', '0', '-i', txt, '-c', 'copy', output]
run(cmd) run(cmd)
os.unlink(txt) os.unlink(txt)
@ -154,5 +157,6 @@ if subtitles:
fd.write(ox.srt.encode(subtitles)) fd.write(ox.srt.encode(subtitles))
duration = ox.avinfo(output)['duration'] duration = ox.avinfo(output)['duration']
print('file duration is %d, edit should be %d' % (duration, edit_duration)) if abs(duration - edit_duration) > 1:
print('file duration is %d, edit was expected to be %d' % (duration, edit_duration))
print('created:', output) print('created:', output)