CenterTrack icon indicating copy to clipboard operation
CenterTrack copied to clipboard

Can't save video

Open bamps53 opened this issue 4 years ago • 13 comments

When I ran demo.py with --save_video argument, I had a below warning and video wasn't saved. I realized it even doesn't create results folder, so I made by myself. Then 'default_nuscenes_mini.mp4.mp4' file appeared in result folder, but the content was empty. I played around some combinations of codecs(MJPG , DIVX) and extensions(.avi , .mp4), but still failed. was it only my environment issue?

[CODE] python demo.py tracking,ddd --load_model ../models/nuScenes_3Dtracking.pth --dataset nuscenes --pre_hm --track_thresh 0.1 --demo ../videos/nuscenes_mini.mp4 --test_focal_length 633 --save_video [ERROR] OpenCV: FFMPEG: tag 0x44495658/'XVID' is not supported with codec id 12 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'

bamps53 avatar Apr 29 '20 13:04 bamps53

I was able to fix the same empty video problem by setting setting the --video_h and --video_w parameters to match the input video dimensions

alxh87 avatar Apr 30 '20 02:04 alxh87

Wow, was it not codec problem?? Thanks, I'll try it!

bamps53 avatar Apr 30 '20 12:04 bamps53

Hello to all,

I tried the same code as bamps530 [Code]: python demo.py tracking,ddd --load_model ../models/nuScenes_3Dtracking.pth --dataset nuscenes --pre_hm --track_thresh 0.1 --demo ../videos/nuscenes_mini.mp4 --test_focal_length 633 --save_video

[Error] OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1' Could not find encoder for codec id 27: Encoder not found

I cant save the video, where I have to build my "results" folder? I built it on this path: CenterTrack/src/results

I also tried to set the video parameters like "Code" --save_video --video_800 --video_450 [Error] demo.py: error: unrecognized arguments: --video_800 --video_450

Please help, thank you in advance

Hunter96av avatar Feb 04 '21 16:02 Hunter96av

you want to set --video_h and --video_w not --video_800 --video_450

results expects to be in the project root, so not CenterTrack/src/results but CenterTrack/results

all that said, I am still faffing about with opencv to get the codec to work and not give me a 500kb file which is corrupt :(

christopherusky avatar Feb 04 '21 17:02 christopherusky

Thank you for your answer :)

[Code] python demo.py tracking,ddd --load_model ../models/nuScenes_3Dtracking.pth --dataset nuscenes --pre_hm --track_thresh 0.1 --demo ../videos/nuscenes_mini.mp4 --test_focal_length 633 --save_video --video_h --video_w

[Error] demo.py: error: argument --video_h: expected one argument

I hope you can help me :)

Hunter96av avatar Feb 04 '21 18:02 Hunter96av

sorry, I wasn't very clear, you want to set --video_h 450 and --video_w 800 like this:

python demo.py tracking,ddd --load_model ../models/nuScenes_3Dtracking.pth --dataset nuscenes --pre_hm --track_thresh 0.1 --demo ../videos/nuscenes_mini.mp4 --test_focal_length 633 --video_h 450 --video_w 800 --save_video

christopherusky avatar Feb 04 '21 18:02 christopherusky

Thank you, but still get an error

[Error]Using node type: (<class 'model.networks.dla.DeformConv'>, <class 'model.networks.dla.DeformConv'>) Warning: No ImageNet pretrain!! loaded ../models/nuScenes_3Dtracking.pth, epoch 70 out_name nuscenes_mini.mp4 OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1' Could not find encoder for codec id 27: Encoder not found

Thank you for your helpfulness

Hunter96av avatar Feb 04 '21 18:02 Hunter96av

@Hunter96av but you are now closer :)

I have just finishing building ffmpeg from source. Now building opencv-python from source to replace the apt install will see if this fixes the codec problem :)

christopherusky avatar Feb 04 '21 19:02 christopherusky

Thanks :) I tried this one:

                    conda remove opencv
		conda install -c menpo opencv
		pip install --upgrade pip
		pip install opencv-contrib-python

but still same error

Hunter96av avatar Feb 04 '21 19:02 Hunter96av

Hi @christopherkettell, you said I'm very close now. I get still the same error, can you help me or give me a solution proposal how I can fix it.

Thank you :)

Hunter96av avatar Feb 07 '21 19:02 Hunter96av

OK, so, when installing opencv-contrib-python you should not need to install opencv-python, as the former includes core + additional modules :)

For me, installing the opencv-contrib-python did not work with FFMEG. To get round this, i cleared opencv from my conda environment, build opencv-contrib from source, then installed the python bindings in my env.

When building from source i included the build flags for ffmpeg

Still didnt work.

Cleared ffmpeg, built from source including all the codecs I wanted / needed, removed and reinstalled opencv-contrib-python again and now its working for me! :)

*small caveat. input videos encoded with H.265 (High Profile) fault when running.

Change over for H.264 problem goes away. So something still not quite right, but the working parts I need are there :)

@Hunter96av Sorry for the delayed response.

christopherusky avatar Feb 09 '21 14:02 christopherusky

I replaced the code line – fourcc = cv2.VideoWriter_fourcc(*'H264') to fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v'). This works for me. Personally, I haven't tried to manually build openCv from source. This OpenCV’s problem is raised due to license issue. See this Hope this help for others!

yktangac avatar Sep 23 '21 04:09 yktangac

抱歉,我不是很清楚,您想像这样设置 --video_h 450 和 --video_w 800 :

python demo.py tracking,ddd --load_model ../models/nuScenes_3Dtracking.pth --dataset nuscenes --pre_hm --track_thresh 0.1 --demo ../videos/nuscenes_mini.mp4 --test_focal_length 633 --video_h 450 --video_w 800 --save_video

hello! I tried the code you provided and got the complete video. But the video is only 1 second. I'm thinking about how to make the total length of the video longer.@christopherusky

ifanshida avatar Jan 06 '22 14:01 ifanshida