u2takey / ffmpeg-go

golang binding for ffmpeg
Apache License 2.0
1.67k stars 167 forks source link

KwArgs with multiple `-map` arguments #1

Closed ljrk0 closed 3 years ago

ljrk0 commented 3 years ago

Hi, great library!

I'm trying to figure out how/whether multiple -map arguments are supported. E.g., in order to add artwork to a file, I'd do

ffmpeg -i "input_file.mp4" -i "Input_file.jpg" --map 1 -map 0  -acodec copy -vcodec copy "output_file.mp4"

(source: https://stackoverflow.com/a/53950948/4453524). However, KwArgs obviously complains that I use the -map key twice. Is there something I'm overlooking?

u2takey commented 3 years ago

check ffmpeg_test.go, will TestCombinedOutput help?

func TestCombinedOutput(t *testing.T) {
    i1 := Input(TestInputFile1)
    i2 := Input(TestOverlayFile)
    out := Output([]*Stream{i1, i2}, TestOutputFile1)
    assert.Equal(t, []string{
        "-i",
        TestInputFile1,
        "-i",
        TestOverlayFile,
        "-map",
        "0",
        "-map",
        "1",
        TestOutputFile1,
    }, out.GetArgs())
}

Hi, great library!

I'm trying to figure out how/whether multiple -map arguments are supported. E.g., in order to add artwork to a file, I'd do

ffmpeg -i "input_file.mp4" -i "Input_file.jpg" --map 1 -map 0  -acodec copy -vcodec copy "output_file.mp4"

(source: https://stackoverflow.com/a/53950948/4453524). However, KwArgs obviously complains that I use the -map key twice. Is there something I'm overlooking?

ljrk0 commented 3 years ago

Yes, thank you -- I totally missed that.


FWIW, I'm toying around a bit by trying to implement some of the functionality of the horrible [1] bash-script https://github.com/KrumpetPirate/AAXtoMP3 at to Go: https://codeberg.org/ljrk/go-aax, while trying to learn a bit about the language, hence my interest in this library!

[1]: Horrible because it mixes POSIX test [ ... ] with bashisms like [[ ... ]] and uses [[ $(($bar > 10)) == "1" ]] instead of [ "$bar" -ge 10 ], etc.

elboletaire commented 1 year ago

Hey @u2takey, doing what's done in that example, what I'm getting is some maps appended to the args string, but I need to specify the maps of my own. This is the command I'm trying to replicate:

ffmpeg -i input-file -c:a copy -c:v libx264 -crf 18 -map 0:v:0 -map 0:m:language:cat output-file

But doing what's done in that example, this is the most closest command I've got:

ffmpeg -i input-file -map 0:a -map 0:v -c copy -c:v libx264 -crf 18 -map 0:m:language:cat output-file

The additional -map 0:a at the beginning makes ffmpeg completely ignore the next -map I'm setting when trying to output it.

Is there any workaround for this?