all parts must have the streams in the same order
This commit is contained in:
parent
0708521a0f
commit
b3df4b1a92
2 changed files with 9 additions and 4 deletions
3
edit.py
3
edit.py
|
@ -198,7 +198,8 @@ if __name__ == '__main__':
|
|||
stream_in = math.ceil(stream_in / (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)
|
||||
if stream_out > stream_in:
|
||||
clip_duration = stream_out - stream_in
|
||||
if clip_duration > 0:
|
||||
videos.append({
|
||||
'oshash': clip['streams'][i],
|
||||
'url': '%s/%s/%sp%s.mp4' % (base_url, clip['item'], stream_resolution, i + 1),
|
||||
|
|
10
ffmpeg.py
10
ffmpeg.py
|
@ -104,12 +104,14 @@ for clip in edit:
|
|||
else:
|
||||
files.append(out)
|
||||
src_info = ox.avinfo(clip['path'])
|
||||
vid = src_info['video'][0]['id']
|
||||
if not src_info['audio']:
|
||||
audio = ['-f', 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=48000']
|
||||
audio_map = []
|
||||
audio_map = ['-map', '0,0', '-map', '1,1']
|
||||
else:
|
||||
aid = src_info['audio'][0]['id']
|
||||
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 = [
|
||||
'ffmpeg',
|
||||
'-nostats', '-loglevel', 'error',
|
||||
|
@ -145,6 +147,7 @@ with open(txt, 'w') as fd:
|
|||
cmd = ['ffmpeg',
|
||||
'-nostats', '-loglevel', 'error',
|
||||
'-y', '-f', 'concat', '-safe', '0', '-i', txt, '-c', 'copy', output]
|
||||
|
||||
run(cmd)
|
||||
os.unlink(txt)
|
||||
|
||||
|
@ -154,5 +157,6 @@ if subtitles:
|
|||
fd.write(ox.srt.encode(subtitles))
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue