Skip to content

[question] different input args for audio and video #156

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

Closed
bbaldino opened this issue Feb 8, 2018 · 2 comments
Closed

[question] different input args for audio and video #156

bbaldino opened this issue Feb 8, 2018 · 2 comments

Comments

@bbaldino
Copy link

bbaldino commented Feb 8, 2018

Thought I'd post something new rather than continuing to post on #16. I'm having trouble setting different inputs for audio and video which use different frameworks, for example the ffmpeg command:

ffmpeg -y -v info -f x11grab -draw_mouse 0 -r 30 -s 1280x720 -thread_queue_size 4096 -i :0.0+0,0 -f alsa -thread_queue_size 4096 -i hw:0,1,0 -acodec aac -strict -2 -ar 44100 -c:v libx264 -preset veryfast -maxrate 2976k -bufsize 5952k -pix_fmt yuv420p -r 30 -crf 25  -g 60 -tune zerolatency -f flv rtmp://a.rtmp.youtube.com/live2/XXX

Which would capture from the desktop for video and the sound card for audio. I tried using setInput("video=xxx:audio=xxx") like the example here, but ffmpeg didn't seem to recognize that format (maybe I screwed something up there or maybe because these input types are specific to the -f arg passed), plus, I think the corresponding -i and -f arguments (as well as other options for both audio and video) need to be in a proper order. For example, I tried this:

val ffmpegArgs = FFmpegBuilder()
        .overrideOutputFiles(true)
        .setVerbosity(FFmpegBuilder.Verbosity.INFO)
        .addExtraArgs("-thread_queue_size", "4096")
        .addExtraArgs("-f", "x11grab")
        .addExtraArgs("-r", "30")
        .addExtraArgs("-s", "1280x720")
        .setInput(":0.0+0,0")
        .addExtraArgs("-f", "alsa")
        .addExtraArgs("-i", "hw:0,1,0")
        .addOutput("rtmp://a.rtmp.youtube.com/live2/XXXX")
            .setAudioCodec("aac")
            .addExtraArgs("-strict", "-2")
            .setAudioBitRate(44100)
            .setVideoCodec("libx264")
            .addExtraArgs("-preset", "veryfast")
            .addExtraArgs("-maxrate", "2976k")
            .addExtraArgs("-bufsize", "5952k")
            .setVideoFrameRate(30.0)
            .setVideoPixelFormat("yuv420p")
            .setConstantRateFactor(25.0)
            .addExtraArgs("-g", "60")
            .addExtraArgs("-tune", "zerolatency")
            .setFormat("flv")
            .done()
        .build()

Which yielded the following ffmpeg command:

ffmpeg -y -v info -thread_queue_size 4096 -f x11grab -r 30 -s 1280x720 -f alsa -i hw:0,1,0 -i :0.0+0,0 -f flv -crf 25 -vcodec libx264 -pix_fmt yuv420p -r 30/1 -acodec aac -b:a 44100 -strict -2 -preset veryfast -maxrate 2976k -bufsize 5952k -g 60 -tune zerolatency rtmp://a.rtmp.youtube.com/live2/XXX

But this doesn't work, as the -i :0.0+0,0 comes after -f alsa, when it needs to come before (in the previous 'block' of args for -f x11grab.

@bbaldino
Copy link
Author

bbaldino commented Feb 8, 2018

After reading the device docs some more, I wonder if this is really an ask for device support, which might look a little bit like the current output scheme where there's a different sub-builder for options for that output? So like:

val ffmpegArgs = FFmpegBuilder()
        .overrideOutputFiles(true)
        .setVerbosity(FFmpegBuilder.Verbosity.INFO)
        .addExtraArgs("-thread_queue_size", "4096")
        .setVideoInputDevice("x11grab")
            .setInput(":0.0+0,0")
            .setVideoFramerate(30)
            .setVideoResoultion("1280x720")
            .done()
        .setAudioInputDevice("alsa")
            .setInput("hw:0,1,0")
            .done()
        .addOutput("rtmp://a.rtmp.youtube.com/live2/XXXX")
            .setAudioCodec("aac")
            .addExtraArgs("-strict", "-2")
            .setAudioBitRate(44100)
            .setVideoCodec("libx264")
            .addExtraArgs("-preset", "veryfast")
            .addExtraArgs("-maxrate", "2976k")
            .addExtraArgs("-bufsize", "5952k")
            .setVideoFrameRate(30.0)
            .setVideoPixelFormat("yuv420p")
            .setConstantRateFactor(25.0)
            .addExtraArgs("-g", "60")
            .addExtraArgs("-tune", "zerolatency")
            .setFormat("flv")
            .done()
        .build()

Euklios added a commit to Euklios/ffmpeg-cli-wrapper that referenced this issue Aug 9, 2024
Euklios added a commit to Euklios/ffmpeg-cli-wrapper that referenced this issue Aug 9, 2024
@Euklios
Copy link
Collaborator

Euklios commented Aug 21, 2024

Closed thanks to #339

@Euklios Euklios closed this as completed Aug 21, 2024
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