3

Why it is so big difference in quality between MPC-CH Windows Media Player and cv2 cv2.VideoCapture('*.mp4') when playing the same file! Codec H. 264 E

How I can improve quality with cv2?

Here is the screenshot Left(cv2) Rigth(MPC-CH): Left cv2, Right MPC-CH Windows Media Player

cv2.namedWindow("Final", 0)
cv2.resizeWindow("Final", 300, 200)
cap = cv2.VideoCapture('1.mp4')
while(cap.isOpened()):
    qwe, frame = cap.read()
    cv2.waitKey(30)
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA) #COLOR_RGB2RGBA
    cv2.imshow('Final',gray)

Any suggestions ?

Dan Mašek
  • 17,852
  • 6
  • 57
  • 85
TheRutubeify
  • 646
  • 1
  • 7
  • 24
  • Interesting. Could you upload some short sample video that can reproduce it? | 5 unrelated mistakes/oddities I see: 1) `cap.isOpened()` will return true even when the end of the video is reached. 2) `cap.read()` may fail (e.g. when end of video is reached) and you never test for that. (and what does `qwe` mean?) 3) `waitKey` should follow `imshow`, this is just odd for little obvious reason. 4) You convert to BGRA and the variable is called `gray` 5) That conversion is useless -- there's no transparency there, and imshow ignores it anyway. – Dan Mašek Aug 10 '17 at 21:37
  • 3) {qwe} - without it (any var) its going to a numerical tuple error! 5) I don't understand what conversion ? – TheRutubeify Aug 10 '17 at 21:52
  • 1
    Regarding #3 -- you may [use _](https://stackoverflow.com/a/5893946/3962537) for that purpose. However, in this case you actually care about this variable -- that's what tells you whether the read succeeded or failed. Regarding #5, I mean that call to `cv2.cvtColor` on the 7th line of code in your question. – Dan Mašek Aug 10 '17 at 21:57
  • For 3# thanks for advice ! 5# cv2.cvtColor I use for regular RGB picture ! Without it the colors are different ! – TheRutubeify Aug 10 '17 at 22:00
  • All that `BGR2BGRA` does is add an alpha plane with all values set to 255. `imshow` ignores that anyway. It shouldn't make any difference to what you see... If it does, that's an interesting thing as well -- which version of OpenCV is this and what platform (I guess windows)? – Dan Mašek Aug 10 '17 at 22:12
  • I touched many variants before BGR2BGRA, to find regular color!) I'm using 3.3.0 on Windows 10, but its still the problem with mp4 quality, my file is too big, I will try to cut it ! What is the best way here to upload a file ? – TheRutubeify Aug 10 '17 at 22:22
  • For a video, I'd say pick any decent file hosting service (I've seen people use google drive or dropbox, for example) and [edit] the question adding the link. | Thanks for the info. That's really interesting about the color conversion, that shouldn't really be happening as far as I can tell. Could you, perhaps, make some screenshots of that, and post it as a new question? (e.g. if you just do `cv2.imshow('Final',frame)`, what does it look like?) – Dan Mašek Aug 10 '17 at 22:33
  • Here is a file with .mov extension, but the case is the same - Could you please check ! https://drive.google.com/open?id=0B_oOlwcaVWfXY081alFKbUpkQXM – TheRutubeify Aug 11 '17 at 00:54
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/151662/discussion-between-therutubeify-and-dan-masek). – TheRutubeify Aug 11 '17 at 01:06

0 Answers0