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

postprocess: add support to merge & remux to matroska (MKV) #1027

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

qnorsten
Copy link
Collaborator

@qnorsten qnorsten commented Jan 1, 2019

This pull request adds support for postprocessing to the matroska format (MKV) as requested in #812
Support for muxing to MKV using either mkvmerge or ffmpeg/avconv. This is activated with the new --output-format option or by specifin output_format: mkv in the config file.

Code is still a work in progress and need to be cleaned up a bit, there might be some bugs left.

It also change the way svtplay-dl detects if a file already exists on disk.
If name of service and video_id is included in filename it will scan for that (just as before),
if not it will just compare the filename without extension (excluding subtitles) (this might need some improvement)

This commit adds support for postprocessing to the matroska format (MKV) using either mkvmerge or ffmpeg/avconv. This is activated with the new --output-format option or by specifin output_format: mkv in the config file.

Code is still a work in progress and need to be cleaned up a bit, there might be some bugs left. 

It also change the way svtplay-dl detects if a file already exists on disk.
If name of service and video_id is included in filename it will scan for that (just as before),
if not it will just compare the filename without extension (excluding subtitles) (this might need some improvement)
@qnorsten qnorsten requested a review from spaam January 1, 2019 13:38
When dealing with multiple subtitles, the singular video and audio tracks is added with each subtitle. This of course results in a multiplied file size which we don't want.
if ext == '.ts':
logging.info('Changing bitstream for TS audio by muxing to MP4')
self.remux_mp4()
orig_filename = u"{0}.mp4".format(name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we do .ts to .mp4 to .mkv? feels way to much. we cant go from .ts to .mkv directly ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For newer ffmpeg versions we do not need to perform this step. I think it works with at least 3.0 and newer on windows. If you make a decision to not support older ffmpeg versions this step could be removed.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i guess we should only support ffmpeg 3.2 or newer. debian stable have 3.2. ubuntu 18.04 (LTS) have 3.4. but ubuntu 16.04 ( Old LTS) have 2.8. they can run the script in docker or something if they want to use something newer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But should you use ffmpeg below 4.x? I'm thinking of the TV4 issue with out of sync.

Copy link
Collaborator Author

@qnorsten qnorsten Jan 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is the case, then just put a note in the readme or something that you shouldn't use older ffmpeg. Or just handle it (recommend/help them to update) when people complain.
Or just tell them to install mkvmerge and this will not be an issue anymore

lib/svtplay_dl/postprocess/__init__.py Outdated Show resolved Hide resolved
lib/svtplay_dl/postprocess/__init__.py Show resolved Hide resolved
lib/svtplay_dl/postprocess/__init__.py Outdated Show resolved Hide resolved
cmd = [self.detect, "-i", orig_filename]
if ext == '.ts':
logging.info('Changing bitstream for TS audio by muxing to MP4 first')
self.remux_mp4()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous comment about this..

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we do this. we should use _clean_ts_audio instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we can use _clean_ts_audio for stuff like HLS files from viafree which have the video track and audio track in the same .ts file?
For merging when we have a seperate audio file it works fine

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I removed this for now, as it seemed to work with viafree .ts files without the remuxing step, and dplay will go through the merging function instead.
Is there any service which have ts audio that we need to change the bitstream for and provides the audio and video in a single .ts file?

lib/svtplay_dl/postprocess/__init__.py Outdated Show resolved Hide resolved
lib/svtplay_dl/postprocess/__init__.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants