GithubHelp home page GithubHelp logo

export error about gyroflow HOT 40 CLOSED

dentex avatar dentex commented on June 8, 2024
export error

from gyroflow.

Comments (40)

abhiTronix avatar abhiTronix commented on June 8, 2024 2

@dentex This is weird.

from gyroflow.

alexagv avatar alexagv commented on June 8, 2024 2

@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.

abhiTronix avatar abhiTronix commented on June 8, 2024 2

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.

dentex avatar dentex commented on June 8, 2024 2

...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.

alexagv avatar alexagv commented on June 8, 2024 1

@abhiTronix Good catch!
Will add it to the branch with the fix for Linux as well.

from gyroflow.

dentex avatar dentex commented on June 8, 2024 1

@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.

dentex avatar dentex commented on June 8, 2024 1

@abhiTronix I try to avoid ppas 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 avatar abhiTronix commented on June 8, 2024 1

@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.

abhiTronix avatar abhiTronix commented on June 8, 2024 1

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.

dentex avatar dentex commented on June 8, 2024 1

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.

ElvinC avatar ElvinC commented on June 8, 2024

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.

dentex avatar dentex commented on June 8, 2024

Yes, it worked.
https://www.dropbox.com/sh/7elhx8gtd8toi34/AACaa6V4kkCwkg9LAEoslqgja?dl=0 (there's a test video)
Thank you very much.

from gyroflow.

abhiTronix avatar abhiTronix commented on June 8, 2024

Hey @ElvinC, WriteGear automatically derives the frame-size for its -s FFmpeg flag from the first incoming frame:

https://github.com/abhiTronix/vidgear/blob/7018d166ddcdb5f585225b79cf87d0ef335cb550/vidgear/gears/writegear.py#L350-L360

therefore manually adding -vf flag for scaling may be interfering with it:

"-vf": "scale=%sx%s" % (out_size[0]*2 if split_screen else out_size[0], out_size[1]),

You can remove -vf flag since -s is internally mapped to -vf=scale, and they both kind of do the same work.

from gyroflow.

ElvinC avatar ElvinC commented on June 8, 2024

@abhiTronix Thanks, I'll change that. Appreciate the help.

from gyroflow.

hyperion11 avatar hyperion11 commented on June 8, 2024

have same problem
this version work
https://github.com/ElvinC/gyroflow/tree/60d27aaafe15b17054f52c2f9786fde429281ff7

from gyroflow.

abhiTronix avatar abhiTronix commented on June 8, 2024

@ElvinC Also, Sorry if I missed it earlier, -pix_fmt is assigned automatically in WriteGear:

https://github.com/abhiTronix/vidgear/blob/7018d166ddcdb5f585225b79cf87d0ef335cb550/vidgear/gears/writegear.py#L363-L370

Please remove it.

from gyroflow.

ElvinC avatar ElvinC commented on June 8, 2024

@abhiTronix That's noted. Thanks again.

from gyroflow.

alexagv avatar alexagv commented on June 8, 2024

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.

hyperion11 avatar hyperion11 commented on June 8, 2024

Hi @alexagv. Thanks for fix. I will check HW encoding! I have relatively old GTX 760.

from gyroflow.

alexagv avatar alexagv commented on June 8, 2024

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.

dentex avatar dentex commented on June 8, 2024

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.

abhiTronix avatar abhiTronix commented on June 8, 2024

@ElvinC @alexagv Thanks for including the purposed fix. Can you please include logging parameter to WriteGear at this line:

out = WriteGear(output_filename=outpath, **output_params)

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.

dentex avatar dentex commented on June 8, 2024

I did a git reset --hard master to restore the original stabilizer.py at d814ddc

Then I added the line you said:
immagine

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.

abhiTronix avatar abhiTronix commented on June 8, 2024

@dentex No, Like I meant this out = WriteGear(output_filename=outpath, logging=True, **output_params).

from gyroflow.

dentex avatar dentex commented on June 8, 2024

oh yeah...

from gyroflow.

abhiTronix avatar abhiTronix commented on June 8, 2024

@dentex Apologies if I didn't explained it correctly.

from gyroflow.

dentex avatar dentex commented on June 8, 2024

Unrecognized option 'crf' in RED :)
I'm retrying removing that line.

from gyroflow.

abhiTronix avatar abhiTronix commented on June 8, 2024

@dentex Thank you so much. But why crf is culprit I wonder. 🤔

from gyroflow.

abhiTronix avatar abhiTronix commented on June 8, 2024

@dentex Please remove these two lines and then try:

gyroflow/stabilizer.py

Lines 504 to 505 in d814ddc

"-vf": "scale=%sx%s" % (out_size[0]*2 if split_screen else out_size[0], out_size[1]),
"-c:v": "libx264",

-crf is not the real error, its secondary one.

from gyroflow.

dentex avatar dentex commented on June 8, 2024

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.

abhiTronix avatar abhiTronix commented on June 8, 2024

@dentex Let's run bare minimum. Remove all these lines:

gyroflow/stabilizer.py

Lines 504 to 509 in d814ddc

"-vf": "scale=%sx%s" % (out_size[0]*2 if split_screen else out_size[0], out_size[1]),
"-c:v": "libx264",
"-crf": "1", # Can't use 0 as it triggers "lossless" which does not allow -maxrate
"-maxrate": "%sM" % bitrate_mbits,
"-bufsize": "%sM" % int(bitrate_mbits * 1.2),
"-pix_fmt": "yuv420p",

from gyroflow.

dentex avatar dentex commented on June 8, 2024
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.

abhiTronix avatar abhiTronix commented on June 8, 2024

@dentex Ok can you paste the output of ffmpeg -encoders

from gyroflow.

abhiTronix avatar abhiTronix commented on June 8, 2024

@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.

dentex avatar dentex commented on June 8, 2024

https://ghostbin.com/paste/AtHTp/ffmpeg

[ffmpeg]

from gyroflow.

abhiTronix avatar abhiTronix commented on June 8, 2024

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.

abhiTronix avatar abhiTronix commented on June 8, 2024

@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.

alexagv avatar alexagv commented on June 8, 2024

@ElvinC Also, Sorry if I missed it earlier, -pix_fmt is assigned automatically in WriteGear:

https://github.com/abhiTronix/vidgear/blob/7018d166ddcdb5f585225b79cf87d0ef335cb550/vidgear/gears/writegear.py#L363-L370

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.

alexagv avatar alexagv commented on June 8, 2024

@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.

alexagv avatar alexagv commented on June 8, 2024

...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)

Hehe, I know 😅
Thanks for testing! At least you got 3x faster export speeds with HW encoding 🚀

from gyroflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.