-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streamlit에서 추론된 영상이 보이지 않는 버그 #36
Comments
nanpuhaha
added a commit
that referenced
this issue
Feb 2, 2023
Open
- fourcc = cv2.VideoWriter_fourcc(*'MP4V')
+ fourcc = cv2.VideoWriter_fourcc(*'H264') 저도 이 방식으로 video_demo.py의 코드를 수정해봤는데 장원님은 나오나요??? |
@JKbin 혹시 ubuntu 에서 opencv 로 h264 codec 비디오 파일 만들기와 동일한 에러가 발생하나요? |
nanpuhaha
added a commit
that referenced
this issue
Feb 2, 2023
python demo/video_demo.py \
/opt/ml/input/final-project-level3-cv-17/mmyolo/demo/demo.mp4 \
/opt/ml/input/final-project-level3-cv-17/mmyolo/work_dirs/yolov8_l_syncbn_fast_8xb16-500e_coco/yolov8_l_syncbn_fast_8xb16-500e_coco.py \
/opt/ml/input/final-project-level3-cv-17/mmyolo/work_dirs/yolov8_l_syncbn_fast_8xb16-500e_coco/epoch_300.pth \
--out /opt/ml/input/delete/test.mp4
02/02 04:11:39 - mmengine - WARNING - The "model" registry in mmyolo did not set import location. Fallback to call `mmyolo.utils.register_all_modules` instead.
02/02 04:11:40 - mmengine - WARNING - The "model" registry in mmdet did not set import location. Fallback to call `mmdet.utils.register_all_modules` instead.
02/02 04:11:40 - mmengine - WARNING - The "task util" registry in mmyolo did not set import location. Fallback to call `mmyolo.utils.register_all_modules` instead.
02/02 04:11:40 - mmengine - WARNING - The "task util" registry in mmdet did not set import location. Fallback to call `mmdet.utils.register_all_modules` instead.
Loads checkpoint by local backend from path: /opt/ml/input/final-project-level3-cv-17/mmyolo/work_dirs/yolov8_l_syncbn_fast_8xb16-500e_coco/epoch_300.pth
02/02 04:11:48 - mmengine - WARNING - The "transform" registry in mmyolo did not set import location. Fallback to call `mmyolo.utils.register_all_modules` instead.
02/02 04:11:48 - mmengine - WARNING - The "transform" registry in mmdet did not set import location. Fallback to call `mmdet.utils.register_all_modules` instead.
02/02 04:11:48 - mmengine - WARNING - The "visualizer" registry in mmyolo did not set import location. Fallback to call `mmyolo.utils.register_all_modules` instead.
02/02 04:11:48 - mmengine - WARNING - The "visualizer" registry in mmdet did not set import location. Fallback to call `mmdet.utils.register_all_modules` instead.
/opt/conda/envs/open-mmlab/lib/python3.8/site-packages/mmengine/visualization/visualizer.py:170: UserWarning: `Visualizer` backend is not initialized because save_dir is None.
warnings.warn('`Visualizer` backend is not initialized '
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'
[ERROR:0@14.933] global cap_ffmpeg_impl.hpp:2991 open Could not find encoder for codec_id=27, error: Encoder not found
[ERROR:0@14.933] global cap_ffmpeg_impl.hpp:3066 open VIDEOIO/FFMPEG: Failed to initialize VideoWriter
[ ] 0/67, elapsed: 0s, ETA:/opt/conda/envs/open-mmlab/lib/python3.8/site-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /opt/conda/conda-bld/pytorch_1639180588308/work/aten/src/ATen/native/TensorShape.cpp:2157.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 67/67, 2.8 task/s, elapsed: 24s, ETA: 0s 실행 명령어가 잘못되었을까요?? |
일단 기존의 inference 된 (인코딩: mpeg4) 비디오 파일을 /usr/bin/ffmpeg -i input.mp4 -vcodec libx264 output.mp4 명령어를 이용해서 h264 인코딩으로 바꾸니 streamlit에서 정상적으로 실행은 되었습니다. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steamlit 공식 문서를 살펴보면, MP4V 인코딩으로 내보낸 영상은 재생되지 않는다고 적혀있다.
공식 문서에서 언급한 StackOverflow post를 보면, 아래와 같이 수정하면 된다고 한다.
이미 MP4V 인코딩으로 추론한 경우
인코딩 확인하는 방법 :
ffprobe
H264 인코딩으로 변환하는 방법:
ffmpeg
ffmpeg usage to encode a video to h264 codec format (StackOverflow)
ubuntu 에서 opencv 로 h264 codec 비디오 파일 만들기
➜ ffmpeg -i input.mp4 -vcodec libx264 -acodec aac output.mp4 ➜ ffmpeg -i input.mp4 -vcodec libx264 output.mp4 # Unknown encoder 'libx264' 라고 뜨는 경우, 아래와 같이 /usr/bin 아래의 ffmpeg를 사용하면 된다. ➜ /usr/bin/ffmpeg -i input.mp4 -vcodec libx264 output.mp4
The text was updated successfully, but these errors were encountered: