Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed cover art being dropped on file split #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 13 additions & 15 deletions album_splitter/split_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@ def split_file(input_file: Path, tracks: List[Track], destination: Path, output_
)
stdout, _ = duration_command.run(stdout=subprocess.PIPE)
file_duration = float(stdout.decode().strip())
outputs: Dict[Path, str] = {}
outputs: List[str] = []
for i, track in enumerate(tracks):
start_timestamp = track.start_timestamp
end_timestamp = file_duration if i == len(tracks) - 1 else tracks[i + 1].start_timestamp
outputs[
destination / (f"{track.title}.{output_format}")
] = f"-vn -c copy -ss {start_timestamp} -to {end_timestamp}"
split_command = ffmpy.FFmpeg(
inputs={
str(input_file): "-y -hide_banner -loglevel error -stats"},
outputs={ str(path): v for path, v in outputs.items()
}
)
try:
split_command.run()
except:
raise Exception("Something went wrong with the splitting procedure. See the error above.") from None
output_file = destination / (f"{track.title}.{output_format}")
outputs.append(output_file)

split_command = ffmpy.FFmpeg(
inputs={str(input_file): f"-y -hide_banner -loglevel error -stats -ss {start_timestamp} -t {end_timestamp}"},
outputs={ str(output_file): "-c copy" }
)
try:
split_command.run()
except:
raise Exception("Something went wrong with the splitting procedure. See the error above.") from None

return list(outputs.keys())
return outputs