Skip to content

Commit

Permalink
fix astream_ordering and add disposition resetting
Browse files Browse the repository at this point in the history
  • Loading branch information
yajrendrag committed Jun 14, 2024
1 parent 864f374 commit e569cbc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions source/stream_arranger/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

**<span style="color:#56adda">0.0.3</span>**
- remove default audio disposition settings and make new 1st audio stream the default
- fix astream_ordering logic

**<span style="color:#56adda">0.0.2</span>**
- fix sory to sort

Expand Down
2 changes: 1 addition & 1 deletion source/stream_arranger/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"on_worker_process": 1
},
"tags": "audio, ffmpeg,library file test",
"version": "0.0.2"
"version": "0.0.3"
}
11 changes: 7 additions & 4 deletions source/stream_arranger/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def arrange_audio_streams(streams, primary_sort_key, channel_sort_direction, lan

all_astreams = [i for i in range(len(streams)) if streams[i]['codec_type'] == 'audio']
astream_order=[]
if primary_sort_key == 'languages':
if primary_sort_key == 'channels':
for c in channels:
for i in range(len(astreams)):
if astreams[i]['channels'] == c: astream_order += [astreams[i]['index']]
Expand Down Expand Up @@ -254,9 +254,12 @@ def on_worker_process(data):
audio_stream_order = arrange_audio_streams(streams, primary_sort_key, channel_sort_direction, langs)

# Set ffmpeg args
ffmpeg_args = ['-hide_banner', '-loglevel', 'info', '-i', str(abspath), '-max_muxing_queue_size', '9999', '-map', '0:v', '-c:v', 'copy']
for stream in audio_stream_order:
ffmpeg_args += ['-map', '0:a:'+str(stream), '-c:a:'+str(stream), 'copy']
ffmpeg_args = ['-hide_banner', '-loglevel', 'info', '-i', str(abspath), '-max_muxing_queue_size', '9999', '-map', '0:v', '-c:v', 'copy', '-disposition:a', '-default']
for i,stream in enumerate(audio_stream_order):
if i == 0:
ffmpeg_args += ['-map', '0:a:'+str(stream), '-c:a:'+str(stream), 'copy', '-disposition:a:0', 'default']
else:
ffmpeg_args += ['-map', '0:a:'+str(stream), '-c:a:'+str(stream), 'copy']
ffmpeg_args += ['-map', '0:s?', '-c:s', 'copy', '-map', '0:d?', '-c:d', 'copy', '-map', '0:t?', '-c:t', 'copy', '-y', str(outpath)]

logger.debug("ffmpeg_args: '{}'".format(ffmpeg_args))
Expand Down

0 comments on commit e569cbc

Please sign in to comment.