Segment-and-Track-Anything icon indicating copy to clipboard operation
Segment-and-Track-Anything copied to clipboard

ffmpeg.error

Open x-ray990011 opened this issue 1 year ago • 23 comments

image

x-ray990011 avatar Apr 21 '23 15:04 x-ray990011

How can I solve the problem of not being able to save the corresponding MP4?

x-ray990011 avatar Apr 21 '23 15:04 x-ray990011

Hi, in the demo.ipynb, by default the output_video has the same format as the input video, i.e. 'output_video': './assets/pl_seg.mp4', since the default fourcc is obtained from the source video. If you want a pl_seg.avi format output, i.e. 'output_video': './assets/pl_seg.avi', please go to "Save results for visualization" part, and change the line "fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))" to: "fourcc = cv2.VideoWriter_fourcc(*"XVID")" or "fourcc = cv2.VideoWriter_fourcc(*"MJPG")"

Besides, we have updated the demo.ipynb, please try the new version to save the video. It supports different formats between input and output, e.g. mp4 input and avi output.

yoxu515 avatar Apr 22 '23 04:04 yoxu515

Hi, in the demo.ipynb, by default the output_video has the same format as the input video, i.e. 'output_video': './assets/pl_seg.mp4', since the default fourcc is obtained from the source video. If you want a pl_seg.avi format output, i.e. 'output_video': './assets/pl_seg.avi', please go to "Save results for visualization" part, and change the line "fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))" to: "fourcc = cv2.VideoWriter_fourcc("XVID")" or "fourcc = cv2.VideoWriter_fourcc("MJPG")"

Besides, we have updated the demo.ipynb, please try the new version to save the video. It supports different formats between input and output, e.g. mp4 input and avi output.

Thank you for your reply. There may be a problem with my screenshot. At that time, I tried MP4 output and reported that error. I tried a new demo. pynb. Thank you again for your reply

x-ray990011 avatar Apr 22 '23 13:04 x-ray990011

Hi, in the demo.ipynb, by default the output_video has the same format as the input video, i.e. 'output_video': './assets/pl_seg.mp4', since the default fourcc is obtained from the source video. If you want a pl_seg.avi format output, i.e. 'output_video': './assets/pl_seg.avi', please go to "Save results for visualization" part, and change the line "fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))" to: "fourcc = cv2.VideoWriter_fourcc("XVID")" or "fourcc = cv2.VideoWriter_fourcc("MJPG")"

Besides, we have updated the demo.ipynb, please try the new version to save the video. It supports different formats between input and output, e.g. mp4 input and avi output.

How can I extract one specific people from the video

x-ray990011 avatar Apr 22 '23 14:04 x-ray990011

Hi, in the demo.ipynb, by default the output_video has the same format as the input video, i.e. 'output_video': './assets/pl_seg.mp4', since the default fourcc is obtained from the source video. If you want a pl_seg.avi format output, i.e. 'output_video': './assets/pl_seg.avi', please go to "Save results for visualization" part, and change the line "fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))" to: "fourcc = cv2.VideoWriter_fourcc("XVID")" or "fourcc = cv2.VideoWriter_fourcc("MJPG")" Besides, we have updated the demo.ipynb, please try the new version to save the video. It supports different formats between input and output, e.g. mp4 input and avi output.

How can I extract one specific people from the video

The 1.0 version has been released, which supports interactive segmentation via WebUI, please have a check.

yoxu515 avatar Apr 23 '23 10:04 yoxu515

Thank you for your hard work, but the issue with saving MP4 that was previously fixed in demo.ipynb has reappeared in APP.PY. You can take a look.

1

x-ray990011 avatar Apr 23 '23 12:04 x-ray990011

This cause https://github.com/opencv/opencv-python/issues/100#issuecomment-394159998

Check: https://pypi.org/project/ffmpegcv/

bhack avatar Apr 23 '23 23:04 bhack

This cause opencv/opencv-python#100 (comment)

Check: https://pypi.org/project/ffmpegcv/

This cause opencv/opencv-python#100 (comment)

Check: https://pypi.org/project/ffmpegcv/

I use the same virtual environment and can generate corresponding MP4 files using demo.ipynb, but cannot generate corresponding MP4 files using app.py. I am not sure if it is a problem with my own environment or something. Could you please confirm again? Thank you for your hard work.

x-ray990011 avatar Apr 24 '23 04:04 x-ray990011

Hi, in the demo.ipynb, by default the output_video has the same format as the input video, i.e. 'output_video': './assets/pl_seg.mp4', since the default fourcc is obtained from the source video. If you want a pl_seg.avi format output, i.e. 'output_video': './assets/pl_seg.avi', please go to "Save results for visualization" part, and change the line "fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))" to: "fourcc = cv2.VideoWriter_fourcc("XVID")" or "fourcc = cv2.VideoWriter_fourcc("MJPG")" Besides, we have updated the demo.ipynb, please try the new version to save the video. It supports different formats between input and output, e.g. mp4 input and avi output.

How can I extract one specific people from the video

The 1.0 version has been released, which supports interactive segmentation via WebUI, please have a check.

I use the same virtual environment and can generate corresponding MP4 files using demo.ipynb, but cannot generate corresponding MP4 files using app.py. I am not sure if it is a problem with my own environment or something. Could you please confirm again? Thank you for your hard work.

x-ray990011 avatar Apr 24 '23 04:04 x-ray990011

The code of app.py partially relies on demo.ipynb, so the problem is probably the same as that in the old demo.ipynb. We are fixing it and the updated version will be released soon.

yoxu515 avatar Apr 24 '23 04:04 yoxu515

app.py 的代码部分依赖于demo.ipynb,所以问题可能与旧的demo.ipynb相同。我们正在修复它,更新版本将很快发布。

app.py 的代码部分依赖于demo.ipynb,所以问题可能与旧的demo.ipynb相同。我们正在修复它,更新版本将很快发布。

Thank you for your reply. Your work has brought us a very good experience. Thank you very much

x-ray990011 avatar Apr 24 '23 05:04 x-ray990011

Hi, the app.py has been updated, please have a try and check whether the video can be saved successfuly.

yoxu515 avatar Apr 24 '23 05:04 yoxu515

Hi, the app.py has been updated, please have a try and check whether the video can be saved successfuly.

We can achieve the effect of demo1 now. Thank you very much. What method is there to keep only the selected part and output the video without retaining the rest? In other words, it is like the movie's green cloth, only retaining the main body and removing the background.

x-ray990011 avatar Apr 24 '23 07:04 x-ray990011

@yoxu515 Are you sure that it is going to work with this codec? Also using your default Swan example I see a warning on gradio related to the browser supported codec: components.py:2203: UserWarning: Video does not have browser-compatible container or codec. Converting to mp4

Then the zip is visible in the UX but not the output video.

bhack avatar Apr 24 '23 11:04 bhack

@yoxu515 Are you sure that it is going to work with this codec? Also using your default Swan example I see a warning on gradio related to the browser supported codec: components.py:2203: UserWarning: Video does not have browser-compatible container or codec. Converting to mp4

Then the zip is visible in the UX but not the output video.

Thank you for your reminder that there may be some incompatibilities, and we will follow up with improvements. In the current version, you can refresh by clicking the 'output-video' component, and the display will be updated.

yamy-cheng avatar Apr 24 '23 12:04 yamy-cheng

In the current version, you can refresh by clicking the 'output-video' component, and the display will be updated.

Really? I don't see any effect.

bhack avatar Apr 24 '23 12:04 bhack

In the current version, you can refresh by clicking the 'output-video' component, and the display will be updated.

Really? I don't see any effect.

Maybe you need to click on the bottom left corner of the 'output-video' component, which is the play button.

yamy-cheng avatar Apr 24 '23 12:04 yamy-cheng

There is any interactive area when done

immagine

bhack avatar Apr 24 '23 12:04 bhack

There is any interactive area when done

immagine

Yes, you can hover your mouse over the bottom left corner of the 'output-video' component, and you will notice that it is a clickable area.

yamy-cheng avatar Apr 24 '23 12:04 yamy-cheng

I've tested on multiple browsers and I don't see any sensible left corner.

bhack avatar Apr 24 '23 12:04 bhack

I've tested on multiple browsers and I don't see any sensible left corner.

image The play button is located in the red box.

yamy-cheng avatar Apr 24 '23 13:04 yamy-cheng

I've tested on multiple browsers and I don't see any sensible left corner.

image After clicking, the output video will be displayed.

yamy-cheng avatar Apr 24 '23 13:04 yamy-cheng

It works but only in the case the input video is already in a "compatible" codec for the 'opencv-python ' pip

bhack avatar Apr 24 '23 14:04 bhack