Comments (40)
@dentex This is weird.
from gyroflow.
@abhiTronix
Vidgear uses libx264 in compression mode, shouldn't it check that ffmpeg has libx264 enabled as well?
Because now it will allow compression mode as long as ffmpeg is installed but it will fail if libx264 is not installed.
If it checked for both it could fallback on non-compression mode?
If i understand the footnote here correctly: https://abhitronix.github.io/vidgear/latest/gears/writegear/non_compression/overview/
from gyroflow.
Vidgear uses libx264 in compression mode, shouldn't it check that ffmpeg has libx264 enabled as well?
@alexagv Yeah, I can add that feature. I'll look into it. Thanks.
from gyroflow.
...try to install Nvidia encoder for ffmpeg...
Yes, this was not so straightforward :)
~/GIT/ffmpeg $ ffmpeg -buildconf
ffmpeg version N-100878-gbfdf03207b Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
configuration: --enable-gpl --enable-libx264 --enable-nonfree --enable-nvenc
libavutil 56. 64.100 / 56. 64.100
libavcodec 58.119.100 / 58.119.100
libavformat 58. 65.101 / 58. 65.101
libavdevice 58. 11.103 / 58. 11.103
libavfilter 7.100.100 / 7.100.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
configuration:
--enable-gpl
--enable-libx264
--enable-nonfree
--enable-nvenc
I tried exporting the same section of a stabilized video with:
- HW encoding enabled:
WriteGear :: DEBUG :: Terminating WriteGear Processes.
frame= 299 fps= 30 q=7.0 Lsize= 72969kB time=00:00:09.94 bitrate=60116.8kbits/s speed=0.998x
video:72966kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.003527%
- HW encoding disabled:
WriteGear :: DEBUG :: Terminating WriteGear Processes.
frame= 299 fps= 12 q=-1.0 Lsize= 76439kB time=00:00:09.87 bitrate=63401.2kbits/s speed=0.386x
video:76434kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.005707%
Full log at: https://ghostbin.com/paste/Bqsz2
(1st chunk is with HW encoding enabled, filename test_HW-enc.mp4
2nd part is without HW encoding, filename test.mp4
)
from gyroflow.
@abhiTronix Good catch!
Will add it to the branch with the fix for Linux as well.
from gyroflow.
@dentex Apologies if I didn't explained it correctly.
It's more about me being noob, don't worry.
17:38:30 :: WriteGear :: DEBUG :: Compression Mode is enabled therefore checking for valid FFmpeg executables.
17:38:30 :: WriteGear :: DEBUG :: Output Parameters: {'-input_framerate': 29.97002997002997, '-vf': 'scale=1920x1080', '-c:v': 'libx264', '-crf': '1', '-maxrate': '20.0M', '-bufsize': '24M', '-pix_fmt': 'yuv420p'}
17:38:30 :: Helper :: DEBUG :: Final FFmpeg Path: ffmpeg
17:38:30 :: Helper :: DEBUG :: FFmpeg validity Test Passed!
17:38:30 :: Helper :: DEBUG :: Found valid FFmpeg Version: `b'4.3.git'` installed on this system
17:38:30 :: WriteGear :: DEBUG :: Found valid FFmpeg executables: `ffmpeg`.
17:38:30 :: WriteGear :: DEBUG :: Compression Mode is configured properly!
FRAME: 0, IDX: 0
17:38:30 :: WriteGear :: DEBUG :: InputFrame => Height:1080 Width:1920 Channels:3
17:38:30 :: WriteGear :: DEBUG :: Setting Input framerate: 29.97002997002997
17:38:30 :: WriteGear :: DEBUG :: Executing FFmpeg command: `ffmpeg -y -f rawvideo -vcodec rawvideo -s 1920x1080 -pix_fmt bgr24 -framerate 29.97002997002997 -i - -vf scale=1920x1080 -c:v libx264 -crf 1 -maxrate 20.0M -bufsize 24M -pix_fmt yuv420p -vcodec libx264 -preset fast /home/samuele/Scrivania/temp/GOPR0843_.mp4`
ffmpeg version 4.3.git Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration:
libavutil 56. 59.100 / 56. 59.100
libavcodec 58.106.100 / 58.106.100
libavformat 58. 56.100 / 58. 56.100
libavdevice 58. 11.102 / 58. 11.102
libavfilter 7. 87.100 / 7. 87.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
Unrecognized option 'crf'.
Error splitting the argument list: Option not found
17:38:30 :: WriteGear :: ERROR :: BrokenPipeError caught, Wrong values passed to FFmpeg Pipe, Kindly Refer Docs!
[...]
and then there's the part above
from gyroflow.
@abhiTronix I try to avoid ppa
s when I can, so I simply compiled latest ffmpeg
from source
$ ffmpeg -buildconf
ffmpeg version N-100878-gbfdf03207b Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
configuration: --enable-gpl --enable-libx264
libavutil 56. 64.100 / 56. 64.100
libavcodec 58.119.100 / 58.119.100
libavformat 58. 65.101 / 58. 65.101
libavdevice 58. 11.103 / 58. 11.103
libavfilter 7.100.100 / 7.100.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
configuration:
--enable-gpl
--enable-libx264
...and indeed it does export the thing.
Thanks for your help.
from gyroflow.
@abhiTronix I try to avoid ppas when I can, so I simply compiled latest ffmpeg from source
@dentex Understandable. Glad it helped.
@ElvinC this issue is resolved at this point. I'll advise to add a option to define custom ffmpeg encoder, so that user can use them according to their need.
from gyroflow.
I tried encoding with x264enc without yuv420p in the output_params and VidGear encoded a video that does not play in Quicktime etc.
@alexagv It covers for current default H264 encoding, therefore any custom encoders like x264enc
and supporting dumb players, you need to specify its requirements accordingly, and also specified in docs.
I see in the code yoi linked that yuv420p is not an option?
yuv420p
is not compatible directly with RAW OpenCV frames, that's why it is not specified.
from gyroflow.
Hehe, I know sweat_smile
Thanks for testing! At least you got 3x faster export speeds with HW encoding rocket
You're more than welcome.
I love what you guys are doing... I'll try to help whenever I can.
from gyroflow.
Not sure what could be causing the error. I'll try to take a look later, but in the meantime you can try this version which uses the standard OpenCV videowriter instead of vidgear https://github.com/ElvinC/gyroflow/tree/60d27aaafe15b17054f52c2f9786fde429281ff7
from gyroflow.
Yes, it worked.
https://www.dropbox.com/sh/7elhx8gtd8toi34/AACaa6V4kkCwkg9LAEoslqgja?dl=0 (there's a test video)
Thank you very much.
from gyroflow.
Hey @ElvinC, WriteGear automatically derives the frame-size for its -s
FFmpeg flag from the first incoming frame:
therefore manually adding -vf
flag for scaling may be interfering with it:
Line 473 in d814ddc
You can remove -vf
flag since -s
is internally mapped to -vf=scale
, and they both kind of do the same work.
from gyroflow.
@abhiTronix Thanks, I'll change that. Appreciate the help.
from gyroflow.
have same problem
this version work
https://github.com/ElvinC/gyroflow/tree/60d27aaafe15b17054f52c2f9786fde429281ff7
from gyroflow.
@ElvinC Also, Sorry if I missed it earlier, -pix_fmt
is assigned automatically in WriteGear:
Please remove it.
from gyroflow.
@abhiTronix That's noted. Thanks again.
from gyroflow.
Hi @dentex and @hyperion11 sorry for the issues, I never tested the VidGear on Linux, can check it out this weekend on a Ubuntu machine. Does any of you have a dedicated graphics card? Would be interesting to test HW encoding on Linux as well using FFmpeg Vaapi.
from gyroflow.
Hi @alexagv. Thanks for fix. I will check HW encoding! I have relatively old GTX 760.
from gyroflow.
Hi @alexagv. Thanks for fix. I will check HW encoding! I have relatively old GTX 760.
If it doesnt work (without HW encoding), try to remove line 499 to 502 in stabilizer.py and see if that works.
I guess you dont have FFmpeg compiled with libx264 enabled :) Will add a check if the encoders exist before using it
As for HW encoding, check what you have installed by running ffmpeg -hwaccels
Will add nvidia option for Linux as well
from gyroflow.
Hi @alexagv thanks for taking a look.
I tried your version, but the problem persists, exporting with HW encoding or not (and also deleting the two lines you mentioned).
It's the same error message as in the 1st post up here.
(I have a Nvidia GTX 850M, on an Asus laptop)
from gyroflow.
@ElvinC @alexagv Thanks for including the purposed fix. Can you please include logging
parameter to WriteGear at this line:
Line 511 in d814ddc
so that we can look at terminal log, and backtrack problem easily. Btw, this error specifically means a wrong FFmpeg parameter being passed through WriteGear's output_params
dictionary parameter or a corrupt/invalid frame is passed to its pipeline.
@dentex You can also directly put logging = True
at above mentioned line to see debugged output on your terminal. Then you can paste that output here so we can see it too.
from gyroflow.
I did a git reset --hard master
to restore the original stabilizer.py
at d814ddc
Then I added the line you said:
But there's no additional logging:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/vidgear/gears/writegear.py", line 315, in write
self.__process.stdin.write(frame.tostring())
BrokenPipeError: [Errno 32] Pipe interrotta
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "gyroflow.py", line 1519, in export_video
self.stab.renderfile(start_time, stop_time, filename[0], out_size = out_size,
File "/home/samuele/GIT/gyroflow/stabilizer.py", line 577, in renderfile
out.write(frame_out)
File "/usr/local/lib/python3.8/dist-packages/vidgear/gears/writegear.py", line 321, in write
raise ValueError # for testing purpose only
ValueError
from gyroflow.
@dentex No, Like I meant this out = WriteGear(output_filename=outpath, logging=True, **output_params)
.
from gyroflow.
oh yeah...
from gyroflow.
@dentex Apologies if I didn't explained it correctly.
from gyroflow.
Unrecognized option 'crf'
in RED :)
I'm retrying removing that line.
from gyroflow.
@dentex Thank you so much. But why crf
is culprit I wonder. 🤔
from gyroflow.
@dentex Please remove these two lines and then try:
Lines 504 to 505 in d814ddc
-crf
is not the real error, its secondary one.
from gyroflow.
I did and it logged this:
17:52:46 :: WriteGear :: DEBUG :: Executing FFmpeg command: `ffmpeg -y -f rawvideo -vcodec rawvideo \
-s 1920x1080 -pix_fmt bgr24 -framerate 29.97002997002997 -i - -crf 1 -maxrate 60.0M -bufsize 72M \
-pix_fmt yuv420p -vcodec libx264 -preset fast /home/samuele/Scrivania/temp/GOPR0843_stab.mp4`
ffmpeg version 4.3.git
[...]
Unrecognized option 'crf'.
So I also removed "-crf": "1"
, but somehow it derives that parameter somewhere else because then it logged:
17:55:32 :: WriteGear :: DEBUG :: Executing FFmpeg command: `ffmpeg -y -f rawvideo -vcodec rawvideo \
-s 1920x1080 -pix_fmt bgr24 -framerate 29.97002997002997 -i - -maxrate 60.0M -bufsize 72M \
-pix_fmt yuv420p -vcodec libx264 -crf 18 -preset fast /home/samuele/Scrivania/temp/GOPR0843_s.mp4`
ffmpeg version 4.3.git
[...]
Unrecognized option 'crf'.
from gyroflow.
@dentex Let's run bare minimum. Remove all these lines:
Lines 504 to 509 in d814ddc
from gyroflow.
18:07:17 :: WriteGear :: DEBUG :: Executing FFmpeg command: `ffmpeg -y -f rawvideo -vcodec rawvideo \
-s 1920x1080 -pix_fmt bgr24 -framerate 29.97002997002997 -i - -vcodec libx264 \
-crf 18 -preset fast /home/samuele/Scrivania/temp/GOPR0843_stabbed.mp4`
ffmpeg version 4.3.git
[...]
Unrecognized option 'crf'.
from gyroflow.
@dentex Ok can you paste the output of ffmpeg -encoders
from gyroflow.
@dentex Your installed FFmpeg build might lack --enable-gpl --enable-libx264
which is required to use -c:v libx264
a.k.a H264 encoder. More info here
from gyroflow.
https://ghostbin.com/paste/AtHTp/ffmpeg
[ffmpeg]
from gyroflow.
https://ghostbin.com/paste/AtHTp/ffmpeg
[ffmpeg]
@dentex @alexagv Yeah h264 encoder is clearly missing. Hence That's why this error. More information here on this issue.
from gyroflow.
@dentex Please use these commands to fix this error:
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo apt-get update && sudo apt install ffmpeg
and you'll be able to use gyroflow master branch as well. Goodluck!
from gyroflow.
@ElvinC Also, Sorry if I missed it earlier,
-pix_fmt
is assigned automatically in WriteGear:Please remove it.
Since we only use h264 encoding here there is no issue specifying yuv420p
I tried encoding with x264enc without yuv420p
in the output_params
and VidGear encoded a video that does not play in Quicktime etc.
I see in the code yoi linked that yuv420p is not an option?
More info regarding on yuv420p
:
https://trac.ffmpeg.org/wiki/Encode/H.264#Encodingfordumbplayers
from gyroflow.
@dentex try to install Nvidia encoder for ffmpeg and run this branch on your Linux machine and see if HW acceleration works for you:
https://github.com/alexagv/gyroflow/tree/vidgear-fix
from gyroflow.
...try to install Nvidia encoder for ffmpeg...
Yes, this was not so straightforward :)
~/GIT/ffmpeg $ ffmpeg -buildconf ffmpeg version N-100878-gbfdf03207b Copyright (c) 2000-2021 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04) configuration: --enable-gpl --enable-libx264 --enable-nonfree --enable-nvenc libavutil 56. 64.100 / 56. 64.100 libavcodec 58.119.100 / 58.119.100 libavformat 58. 65.101 / 58. 65.101 libavdevice 58. 11.103 / 58. 11.103 libavfilter 7.100.100 / 7.100.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 configuration: --enable-gpl --enable-libx264 --enable-nonfree --enable-nvenc
I tried exporting the same section of a stabilized video with:
- HW encoding enabled:
WriteGear :: DEBUG :: Terminating WriteGear Processes. frame= 299 fps= 30 q=7.0 Lsize= 72969kB time=00:00:09.94 bitrate=60116.8kbits/s speed=0.998x video:72966kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.003527%
- HW encoding disabled:
WriteGear :: DEBUG :: Terminating WriteGear Processes. frame= 299 fps= 12 q=-1.0 Lsize= 76439kB time=00:00:09.87 bitrate=63401.2kbits/s speed=0.386x video:76434kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.005707%
Full log at: https://ghostbin.com/paste/Bqsz2
(1st chunk is with HW encoding enabled, filename
test_HW-enc.mp4
2nd part is without HW encoding, filenametest.mp4
)
Hehe, I know 😅
Thanks for testing! At least you got 3x faster export speeds with HW encoding 🚀
from gyroflow.
Related Issues (20)
- Resolution adaptation
- Attempting to use h264_nvenc gives `BrokenPipeError`
- cli.py is broken HOT 1
- Can't join discord HOT 1
- 1.0 version crashing after uploading blackbox log
- v1.0.0 Blackbox data from INAV not imported HOT 1
- Sensor logger iPhone
- Runcam Thumb HOT 1
- Phone app logs error: unsupported file format HOT 1
- Add some test video and data
- Blue spinning circle when syncing
- Gyroflow exported video issue HOT 3
- Gyroflow preview image goes black when motion data is added - V1.01 & V1.0
- Batch video processing or command line interface?
- Video lag after export HOT 1
- Lens profile disappeared after failure to export HOT 1
- Too few sync points
- Error with export GF845M
- Can't add motion data to lens calibrator
- Black Orbs Visible Throughout footage HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gyroflow.