I'm trying to read some video files that have mp4 format using OpenCV python. I didn't have any problem with any other mp4 video that I have used so far, but for some reason, videocapture cannot read these mp4 video files. My problem is not like this (I already applied this renaming of mmpeg when I first installed opencv). Besides, as I mentioned earlier videocapture can read other mp4 videos, but not these ones. I also tried to convert the video into avi, but still videocapture cannot read the video (I use other avi files with no problem). The videos that I'm using come from this dataset.
Asked
Active
Viewed 2,876 times
1
-
Can you play the files without a problem with your favorite OS media player? – Adi Shavit Feb 13 '17 at 08:28
-
Do a rewrap using ffmpeg. `ffmpeg -i in.mp4 -c copy out.mp4`. The H.264 bitstream in the source MP4s is Annex B. That may be the issue. – Gyan Feb 13 '17 at 09:34
-
@Mulvya rewrapping helped. Thank you! – Miranda Feb 13 '17 at 14:17
-
@Mulvya Can you please post it as an answer? – Miranda Feb 13 '17 at 14:19
1 Answers
5
Do a rewrap using ffmpeg.
ffmpeg -i in.mp4 -c copy out.mp4.
The H.264 bitstream in the source MP4s is Annex B, which is not expected.

Gyan
- 85,394
- 9
- 169
- 201
-
1Since ffmpeg can read, then opencv should be able to read it in a way. This solution resolved the issue I am facing, thanks a lot, but I guess there should be a resolution other than having to do it manually. Thanks dear – Abdallah Nasir Mar 25 '18 at 12:54