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

Import degrades mkv files #138

Closed
Cycor opened this issue Jan 10, 2022 · 12 comments
Closed

Import degrades mkv files #138

Cycor opened this issue Jan 10, 2022 · 12 comments
Labels
help wanted Extra attention is needed

Comments

@Cycor
Copy link

Cycor commented Jan 10, 2022

When importing mkv files you are using
ffmpeg -i file.mkv file.mp4
this causes ffmpeg to recode the mkv instead of just remuxing it, reducing the quality.

I usually use this line to remux, but you might need to check if the codec can be used in an mp4 container
ffmpeg -i input.mkv -movflags +faststart -c:v copy -c:a copy -c:s copy -c:t copy ouput.mp4

@bbilly1
Copy link
Member

bbilly1 commented Jan 10, 2022

Yeah, you are right, I just used the catch all command to convert any file to mp4, not just mkv. What would be a good solution for that? Some kind of a mapping of file extension to optimal ffmpeg command? This way, even when ingesting media files with different file types, the mapping could look up the optimal command. Do you mind looking into it? Find the ideal ffmpeg command for the different filetypes?

@Cycor
Copy link
Author

Cycor commented Jan 10, 2022

sure, i already got a python script that uses ffprobe to figure out what needs to be converted and what can be remuxed so I can cobble something together from that.

@bbilly1
Copy link
Member

bbilly1 commented Jan 10, 2022

Well... A PR would be even better! :-) I think you have found the ManualImport class, and the ffmpeg command here, call with subprocess? https://github.com/bbilly1/tubearchivist/blob/edc9f3fe156127a68b321f3595078e19a3f6c7af/tubearchivist/home/src/reindex.py#L558

So I was thinking to have an additional method for that class that takes the filename, looks at the file ending and returns the optimal ffmpeg command to be called. Or what do you think?

@Cycor
Copy link
Author

Cycor commented Jan 10, 2022

https://gist.github.com/Cycor/e6e2a1c4e2d907bf7b1a552b7a417472

this is the script i'm using atm, it's still a work in progrss but for yt-dlp downloads it works fine.
I got the original read_video_info from another project so it contains a lot of unused stuff.

@bbilly1
Copy link
Member

bbilly1 commented Jan 10, 2022

OK, I think we should focus on supporting conversion for three file types: mkv, webm, mov, maybe wmv? I don't know, but why not? So basically we just need the appropriate ffmpeg command that can convert each of these file types to standard mp4. Then we mention in the wiki, which filetypes are supported, and if people have something wired, they can still convert it them self's and ingest the mp4.

Otherwise this will get out of hand quickly. :-)

@Cycor
Copy link
Author

Cycor commented Jan 10, 2022

ffmpeg is insanely good, so I would just let it do it's thing, allow all known types, my script doesn't really look at the source except for if a recode or remux is needed, if it is needed it does a standard x264 conversion (hardware accelerated in my case but not needed) otherwise a copy, that works on all ffmpeg supported types, we just need to check the exitcode and result filesize to be sure if it worked.

@bbilly1
Copy link
Member

bbilly1 commented Jan 10, 2022

OK, sounds good, looking forward to your implementation! :-)

@bbilly1 bbilly1 added bug Something isn't working help wanted Extra attention is needed labels Jan 13, 2022
@bbilly1
Copy link
Member

bbilly1 commented Jan 27, 2022

@Cycor Were you able to look at this one? Just to make sure we don't end up doing double the work. :-)

@Cycor
Copy link
Author

Cycor commented Jan 28, 2022

I'll try to push something this weekend, haven't gotten a lot of free time last week, got most of the code ready and I'm doing a bunch of test runs with weird codecs to get the best settings to keep the quality/subtitles/metadata etc and copy the data if possible.

bbilly1 added a commit that referenced this issue Mar 30, 2022
@bbilly1
Copy link
Member

bbilly1 commented Mar 30, 2022

closing this for now, we can revisit that again when improving the offline import functionality.

@bbilly1 bbilly1 closed this as completed Mar 30, 2022
@dot-mike
Copy link
Contributor

Any news regards this?

@bbilly1
Copy link
Member

bbilly1 commented Jan 14, 2023

Same state as mentioned in the wiki. I'm probably not going to extend the manual import any further for the foreseeable future. If you have any specific requirements, convert the videos first with your preferred settings. Or if you feel strongly about it, make a PR.

@bbilly1 bbilly1 removed the bug Something isn't working label Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants