question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

example/demo.py: video writer could not be opened

See original GitHub issue

The video example does not work. I get the following error:

File "visdom_demo.py", line 28, in <module> viz.video(tensor=video) File "/home/bk17/anaconda3/envs/pytorch/lib/python3.6/site-packages/visdom/__init__.py", line 420, in video assert writer.isOpened(), 'video writer could not be opened' AssertionError: video writer could not be opened

I’m using the video mentioned in the code comments as the input file. The installed opencv version is 3.2.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bisheshcommented, Jul 21, 2017

Sorry, missed this for a while and then later was waiting to test OpenCV set-up properly before posting. The problem is with the choice of codec in fourcc variable in the code you linked above. Would it be possible to support other codecs (like letting user choose it) ?

fourcc = cv2.VideoWriter_fourcc(
                    chr(ord('T')),
                    chr(ord('H')),
                    chr(ord('E')),
chr(ord('O'))

I tried a simple test code in my set-up and it works for certain codecs but not with the one used in visdom:

import cv2
import torch
import numpy
t = torch.zeros(10,100,100,3)
t1 = torch.ones(100,100,3)
for idx in range(t.size()[0]):
    if idx % 3 == 0:
        t[idx,:,:,:] = t1
fw, fh = t.size()[1], t.size()[2]
fourcc = cv2.VideoWriter_fourcc(*'MJPG') # works
#fourcc = cv2.VideoWriter_fourcc(*'XVID') # Does not work
# fourcc = visdom fourcc also does not work

out = cv2.VideoWriter('../results/output.avi',fourcc, 2.0, (fw, fh))
assert out.isOpened(), 'video writer could not be opened'

for idx in range(t.size()[0]):
    out.write(t[idx,:,:,:].numpy())
out.release() 
0reactions
JackUrbcommented, Jan 22, 2019

@GregorKoehler - We haven’t revisited this, though we’d be happy to accept a PR that adds an optional flag to the python version of the video function for other codecs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

example/demo.py: video writer could not be opened · Issue #106
The video example does not work. I get the following error: File "visdom_demo.py", line 28, in viz.video(tensor=video) File ...
Read more >
OpenCV videowrite doesn't write video - Stack Overflow
On windows 7 and using Python 2.7 and OpenCV 2.4.8, I experienced the fact that if the file NAME is "output.mpg" would not...
Read more >
cv::VideoWriter Class Reference - OpenCV
Returns true if video writer has been successfully initialized. More... virtual bool, open (const String &filename, int fourcc, double fps, Size frameSize, bool ......
Read more >
Debugging HTML - Learn web development | MDN
So there we have it, an introduction to debugging HTML, which should give you some useful skills to count on when you start...
Read more >
OpenCV Error creating VIdeoWriter object - Intel Communities
Solved: I'm on windows 10 (64 bit) and finally got OpenVino installed and working correctly using the windows installation tool.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found