Description
Describe the bug
When muxing an MKV file with multiple tracks, it appears that each track is loaded individually from the file.
As a result, if a 1GB MKV file contains 10 subtitle tracks, a total of approximately 10GB of data will be read from the drive. This process is highly inefficient and slow.
To Reproduce
Use an MKV file with multiple tracks as the input.
mkv = pymkv.MKVFile(file_path=mkv_input_path, mkvmerge_path=mkvmerge_path)
print(mkv.command(mkv_output_path))
The mux command includes the input file multiple times, which apparently causes the file to be read multiple times.
Open a disk I/O viewer and run the mux process.
mkv.mux(mkv_output_path)
The viewer should display I/O read usage roughly equal to the file size multiplied by the track count.
Expected behavior
Each input file should only be read once. Selecting multiple tracks within a single input file should resolve this issue.
My old implementation for extracting subtitles works this way. However, keep in mind that this code is more of a proof of concept than a well-polished solution.
Screenshots
none
Software (please complete the following information):
- OS: Arch Linux
- MKVToolNix version v88.0 Flatpak
- pymkv2==2.0.3
Additional context
Output of an example mkv file with mkv.command(output_path)
:
flatpak run org.bunkus.mkvtoolnix-gui mkvmerge -o /home/user/file.mks --title File --language 0:en --default-track 0:0 --forced-track 0:0 --hearing-impaired-flag 0:0 --visual-impaired-flag 0:0 --original-flag 0:0 --commentary-flag 0:0 -d 0 -A -S /home/user/file.mkv --track-name 1:Stereo --language 1:de --default-track 1:1 --forced-track 1:0 --hearing-impaired-flag 1:0 --visual-impaired-flag 1:0 --original-flag 1:0 --commentary-flag 1:0 -D -a 1 -S /home/user/file.mkv --track-name 2:Stereo --language 2:en --default-track 2:0 --forced-track 2:0 --hearing-impaired-flag 2:0 --visual-impaired-flag 2:0 --original-flag 2:0 --commentary-flag 2:0 -D -a 2 -S /home/user/file.mkv --track-name 3:Surround 5.1 --language 3:de --default-track 3:0 --forced-track 3:0 --hearing-impaired-flag 3:0 --visual-impaired-flag 3:0 --original-flag 3:0 --commentary-flag 3:0 -D -a 3 -S /home/user/file.mkv --track-name 4:Surround 5.1 --language 4:de --default-track 4:0 --forced-track 4:0 --hearing-impaired-flag 4:0 --visual-impaired-flag 4:0 --original-flag 4:0 --commentary-flag 4:0 -D -a 4 -S /home/user/file.mkv --track-name 5:Surround 5.1 --language 5:en --default-track 5:0 --forced-track 5:0 --hearing-impaired-flag 5:0 --visual-impaired-flag 5:0 --original-flag 5:0 --commentary-flag 5:0 -D -a 5 -S /home/user/file.mkv --track-name 6:Surround 5.1 --language 6:en --default-track 6:0 --forced-track 6:0 --hearing-impaired-flag 6:0 --visual-impaired-flag 6:0 --original-flag 6:0 --commentary-flag 6:0 -D -a 6 -S /home/user/file.mkv --track-name 7:Stereo --language 7:und --default-track 7:0 --forced-track 7:0 --hearing-impaired-flag 7:0 --visual-impaired-flag 7:0 --original-flag 7:0 --commentary-flag 7:0 -D -a 7 -S /home/user/file.mkv --track-name 8:Stereo --language 8:en --default-track 8:0 --forced-track 8:0 --hearing-impaired-flag 8:0 --visual-impaired-flag 8:0 --original-flag 8:0 --commentary-flag 8:0 -D -a 8 -S /home/user/file.mkv --language 9:de --default-track 9:0 --forced-track 9:0 --hearing-impaired-flag 9:0 --visual-impaired-flag 9:0 --original-flag 9:0 --commentary-flag 9:0 -D -A -s 9 /home/user/file.mkv --language 10:de --default-track 10:0 --forced-track 10:0 --hearing-impaired-flag 10:0 --visual-impaired-flag 10:0 --original-flag 10:0 --commentary-flag 10:0 -D -A -s 10 /home/user/file.mkv --language 11:en --default-track 11:0 --forced-track 11:0 --hearing-impaired-flag 11:0 --visual-impaired-flag 11:0 --original-flag 11:0 --commentary-flag 11:0 -D -A -s 11 /home/user/file.mkv --language 12:de --default-track 12:0 --forced-track 12:0 --hearing-impaired-flag 12:0 --visual-impaired-flag 12:0 --original-flag 12:0 --commentary-flag 12:0 -D -A -s 12 /home/user/file.mkv --track-order 0:0,0:1,0:2,0:3,0:4,0:5,0:6,0:7,0:8,0:9,0:10,0:11,0:12