Luffy-do commited on
Commit
76dd88f
·
verified ·
1 Parent(s): 88464d8

Update helper_func/mux.py with custom content

Browse files
Files changed (1) hide show
  1. helper_func/mux.py +20 -3
helper_func/mux.py CHANGED
@@ -286,7 +286,7 @@ CODECS = {
286
  }
287
  }
288
 
289
- async def hardmux_vid(vid_filename, sub_filename, msg, crf='23', preset='medium', resolution='original', codec='h264', fps='original', custom_filename=None, audio_bitrate='128k'):
290
  chat_id = msg.chat.id
291
 
292
  # Set active process
@@ -364,8 +364,25 @@ async def hardmux_vid(vid_filename, sub_filename, msg, crf='23', preset='medium'
364
  '-preset', preset,
365
  '-c:a', 'aac',
366
  '-b:a', audio_bitrate,
367
- '-map', '0:v:0',
368
- '-map', '0:a:0?',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
  '-map_metadata', '-1', # Remove all metadata
370
  '-sn', # Remove all subtitle streams
371
  ])
 
286
  }
287
  }
288
 
289
+ async def hardmux_vid(vid_filename, sub_filename, msg, crf='23', preset='medium', resolution='original', codec='h264', fps='original', custom_filename=None, audio_bitrate='128k', audio_track='all'):
290
  chat_id = msg.chat.id
291
 
292
  # Set active process
 
364
  '-preset', preset,
365
  '-c:a', 'aac',
366
  '-b:a', audio_bitrate,
367
+ ])
368
+
369
+ # Handle audio track mapping
370
+ if audio_track == 'all':
371
+ # Map all audio tracks
372
+ command.extend([
373
+ '-map', '0:v:0', # First video stream
374
+ '-map', '0:a', # All audio streams
375
+ ])
376
+ else:
377
+ # Map specific audio track (convert from 1-based to 0-based indexing)
378
+ audio_stream_index = int(audio_track) - 1
379
+ command.extend([
380
+ '-map', '0:v:0', # First video stream
381
+ '-map', f'0:a:{audio_stream_index}', # Specific audio stream
382
+ ])
383
+
384
+ # Add remaining parameters
385
+ command.extend([
386
  '-map_metadata', '-1', # Remove all metadata
387
  '-sn', # Remove all subtitle streams
388
  ])