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

[Proposal]: Allow configuration of input parameters #335

Closed
4 tasks done
HeeebsInc opened this issue Oct 8, 2022 · 6 comments
Closed
4 tasks done

[Proposal]: Allow configuration of input parameters #335

HeeebsInc opened this issue Oct 8, 2022 · 6 comments
Labels
INVALID 🛑 This doesn't seem right or non-applicable or missing information PROPOSAL 📩 A proposal/proposition

Comments

@HeeebsInc
Copy link

Issue guidelines

Issue Checklist

  • I have searched open or closed issues and found nothing related to my idea.
  • I have read the Documentation and it doesn't mention anything about my idea.
  • To my best knowledge, my idea wouldn't break something for other users.

Describe your Idea

Like output params, allow configuration of input parameters when using WriteGear. I recently faced an issue where I needed to have
-framerate 1
in the input parameters and the only way to get that working with vidgear was to modify the source code and replace
input_parameters ={} --> input_parameters= {'framerate': 1}
inside of writegear.py

Use Cases

when creating a video that you instead of be encoded at 1 fps. Using h265, trying to do this without having the additional input parameter created a video that is not actually 1 fps.

Any other Relevant Information?

No response

@HeeebsInc HeeebsInc added the PROPOSAL 📩 A proposal/proposition label Oct 8, 2022
@welcome
Copy link

welcome bot commented Oct 8, 2022

Thanks for opening this issue, a maintainer will get back to you shortly!

In the meantime:

  • Read our Issue Guidelines, and update your issue accordingly. Please note that your issue will be fixed much faster if you spend about half an hour preparing it, including the exact reproduction steps and a demo.
  • Go comprehensively through our dedicated FAQ & Troubleshooting section.
  • For any quick questions and typos, please refrain from opening an issue, as you can reach us on Gitter community channel.

@abhiTronix
Copy link
Owner

abhiTronix commented Oct 9, 2022

Like output params, allow configuration of input parameters when using WriteGear. I recently faced an issue where I needed to have
-framerate 1
in the input parameters and the only way to get that working with vidgear was to modify the source code and replace
input_parameters ={} --> input_parameters= {'framerate': 1}
inside of writegear.py

@HeeebsInc That's what -ffpreheaders exclusive attribute is for in WriteGear API's output_params dictionary parameter, i.e. changing input parameters. Kindly go through docs properly before opening issue here.

@abhiTronix abhiTronix added the INVALID 🛑 This doesn't seem right or non-applicable or missing information label Oct 9, 2022
@abhiTronix
Copy link
Owner

abhiTronix commented Oct 9, 2022

@HeeebsInc Also, 'framerate': 1 can be assigned just by putting output_params = {"-input_framerate": 1.0}.

@HeeebsInc
Copy link
Author

HeeebsInc commented Nov 19, 2022

good afternoon @abhiTronix - I got the pipeline working only by modifying the source code. Before modifying and pulling the most recent release I see the parsing logic for ffpreheaders is not working. When passing

output_params = {
            '-ffpreheaders': ['-framerate', 1],
            '-c:v': 'libx265',
            '-x265-params': '"crf=0:lossless=1:qp=0:keyint=1:ref=1:no-open-gop=1:weightp=0:weightb=0:cutree=0:rc-lookahead=0:bframes=0:scenecut=0:b-adapt=0:repeat-headers=1"',
            '-pix_fmt': 'yuv420p',
            '-r': 1
}
out = WriteGear(output_filename=video_file, logging = True, **output_params)

I get the following output

18:20:12 :: WriteGear :: DEBUG :: Compression Mode is enabled therefore checking for valid FFmpeg executables.
18:20:12 :: WriteGear :: DEBUG :: Output Parameters: {'-ffpreheaders': ['-framerate', 1], '-c:v': 'libx265', '-x265-params': '"crf=0:lossless=1:qp=0:keyint=1:ref=1:no-open-gop=1:weightp=0:weightb=0:cu
tree=0:rc-lookahead=0:bframes=0:scenecut=0:b-adapt=0:repeat-headers=1"', '-pix_fmt': 'yuv420p', '-r': 1}
18:20:12 :: Helper :: DEBUG :: Final FFmpeg Path: ffmpeg
18:20:12 :: Helper :: DEBUG :: FFmpeg validity Test Passed!
18:20:12 :: Helper :: DEBUG :: Found valid FFmpeg Version: `b'3.4.11-0ubuntu0.1'` installed on this system
18:20:12 :: WriteGear :: DEBUG :: Found valid FFmpeg executables: `ffmpeg`.
18:20:12 :: WriteGear :: DEBUG :: Compression Mode is configured properly!
18:20:12 :: WriteGear :: DEBUG :: InputFrame => Height:540 Width:960 Channels:3
18:20:12 :: WriteGear :: DEBUG :: Executing FFmpeg command: `ffmpeg -y -f rawvideo -vcodec rawvideo -s 960x540 -pix_fmt bgr24 -i - -ffpreheaders ['-framerate', 1] -x265-params "crf=0:lossless=1:qp=0:k
eyint=1:ref=1:no-open-gop=1:weightp=0:weightb=0:cutree=0:rc-lookahead=0:bframes=0:scenecut=0:b-adapt=0:repeat-headers=1" -pix_fmt yuv420p -r 1 -vcodec libx265 -crf 18 -preset fast /Vid.mp4`
ffmpeg version 3.4.11-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avres
ample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreet
ype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enab
le-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enabl
e-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-lib
iec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Unrecognized option 'ffpreheaders'.
Error splitting the argument list: Option not found
18:20:12 :: WriteGear :: ERROR :: BrokenPipeError caught, Wrong values passed to FFmpeg Pipe, Kindly Refer Docs!

Vid gear is passing pre-headers as a list in the ffmpeg argument when it should be parsing it and passing in each argument of the list. so should be the following

ffmpeg -y -f rawvideo -vcodec rawvideo -s 960x540 -pix_fmt bgr24 -i - -framerate 1 -x265-params "crf=0:lossless=1:qp=0:k
eyint=1:ref=1:no-open-gop=1:weightp=0:weightb=0:cutree=0:rc-lookahead=0:bframes=0:scenecut=0:b-adapt=0:repeat-headers=1" -pix_fmt yuv420p -r 1 -vcodec libx265 -crf 18 -preset fast /Vid.mp4`

@HeeebsInc
Copy link
Author

HeeebsInc commented Nov 19, 2022

ffmpeg -y -f rawvideo -vcodec rawvideo -framerate 1 -s 960x540 -pix_fmt bgr24 -i - -framerate 1 -x265-params "crf=0:lossless=1:qp=0:keyint=1:ref=1:no-open-gop=1:weightp=0:weightb=0:cutree=0:rc-lookahead=0:bframes=0:scenecut=0:b-adapt=0:repeat-headers=1" -pix_fmt yuv420p -r 1 -vcodec libx265 -crf 18 -preset fast /Vid.mp4

this is the command I was hoping for. In order to get -framerate to the left you need to modify the vidgear.py file and add
input_parameters={'-framerate': 1} to self.__Preprocess

or am I missing something? -ffpreheaders: ['-framerate', 1] does not work

@HeeebsInc
Copy link
Author

following up on this again -

in order to allow for input_framerate less than 5, we need to modify this

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
INVALID 🛑 This doesn't seem right or non-applicable or missing information PROPOSAL 📩 A proposal/proposition
Projects
None yet
Development

No branches or pull requests

2 participants