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

[Feature request] Add option to preserve all audio tracks. #18

Open
70sh1 opened this issue Nov 23, 2023 · 6 comments
Open

[Feature request] Add option to preserve all audio tracks. #18

70sh1 opened this issue Nov 23, 2023 · 6 comments

Comments

@70sh1
Copy link

70sh1 commented Nov 23, 2023

This would be nice.

@70sh1
Copy link
Author

70sh1 commented Nov 23, 2023

Apparently, replacing -map v:0? -map a:0? -map s:-1? part of the ffmpeg command with map 0 does the trick. Not tested with subtitles or multiple video tracks.

@70sh1
Copy link
Author

70sh1 commented Nov 23, 2023

local o = {
    include_all_tracks = false,
    ...
}
if o.include_all_tracks then
    cmds:arg("-map", "0")
else
    cmds:arg("-map", string.format("v:%s?", mp.get_property_number("current-tracks/video/id", 0) - 1))
    cmds:arg("-map", string.format("a:%s?", mp.get_property_number("current-tracks/audio/id", 0) - 1))
    cmds:arg("-map", string.format("s:%s?", mp.get_property_number("current-tracks/sub/id", 0) - 1))
end

Seems to work. Again, not tested with subtitles or multiple video tracks.

@snylonue
Copy link
Owner

snylonue commented Nov 23, 2023

I'll refer to ffmpeg's doc later and implement this feature.
pr is welcome.

@snylonue
Copy link
Owner

Can you try #19?
remember to set select_all_streams=yes in your config file

@70sh1
Copy link
Author

70sh1 commented Nov 26, 2023

Testing on a video without subs results in the following error:

[slicing_copy] stderr: Stream map 's' matches no streams.
[slicing_copy] To ignore this, add a trailing '?' to the map.
[slicing_copy] Failed to set value 's' for option 'map': Invalid argument

Following this suggestion seems to fix the issue:

--
if (o.select_all_streams) then
        cmds:arg("-map", "v?")
        cmds:arg("-map", "a?")
        cmds:arg("-map", "s?")
    else
--

@snylonue
Copy link
Owner

updated

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

No branches or pull requests

2 participants