ultralytics / yolov5

YOLOv5 πŸš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
51.2k stars 16.43k forks source link

Why does the generated video have no sound? #11269

Closed lemon1022 closed 1 year ago

lemon1022 commented 1 year ago

Search before asking

Question

I detected a video using yolov5-7.0, and the generated video has no sound.

Additional

No response

github-actions[bot] commented 1 year ago

πŸ‘‹ Hello @lemon1022, thank you for your interest in YOLOv5 πŸš€! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a πŸ› Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 πŸš€

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 πŸš€!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics
glenn-jocher commented 1 year ago

When using YOLOv5 for object detection on videos, the output video typically doesn't contain audio. This is because the focus of YOLOv5 is on object detection in images, and audio processing is not included in the framework. However, you can easily add the audio from the original video to the generated video using external tools such as moviepy or FFmpeg.

Can you please provide more details about the software and tools you are using, as well as the steps you followed to generate the video?

lemon1022 commented 1 year ago

When using YOLOv5 for object detection on videos, the output video typically doesn't contain audio. This is because the focus of YOLOv5 is on object detection in images, and audio processing is not included in the framework. However, you can easily add the audio from the original video to the generated video using external tools such as moviepy or FFmpeg.

Can you please provide more details about the software and tools you are using, as well as the steps you followed to generate the video?

Thank you for your reply, I imported and run the project directly with pycharm, do you mean that I need to use other ways to synthesize the audio into the video?

glenn-jocher commented 1 year ago

@lemon1022 it depends on what you're trying to achieve. If you want to add audio to the video output of YOLOv5, you can use a video editing software like Adobe Premiere or Final Cut Pro to combine the YOLOv5 output video with an audio track. Alternatively, you can use a Python library like moviepy to programmatically add audio to the video output. Here's an example of how to add audio to a video using moviepy:

import moviepy.editor as mp

video = mp.VideoFileClip("yolov5_output.mp4")
audio = mp.AudioFileClip("audio.wav")
final_clip = video.set_audio(audio)
final_clip.write_videofile("yolov5_output_with_audio.mp4")

I hope that helps! Let me know if you have any other questions.

lemon1022 commented 1 year ago

I hope that helps! Let me know if you have any other questions.

It helps, thanks!

glenn-jocher commented 1 year ago

@lemon1022 @lemon1022 you're welcome! If you have any other questions or concerns, please don't hesitate to ask. I am always happy to help.

dandandan1983 commented 7 months ago

Hi. Is it possible to save audio in video without FFmpeg? My input video has audio by default. After Yolo 8 it leaves audio. Is there any parameters to save audio? Thanks.

glenn-jocher commented 7 months ago

Hi there! πŸ‘‹ Unfortunately, YOLOv5 does not natively support saving audio in the output video directly within its processing flow, as its main focus is on image and video frame analysis for object detection. Audio handling is not part of its functionality. Thus, there aren't any parameters within YOLOv5 to retain or manipulate audio tracks in videos.

To include audio in your output video after processing with YOLOv5, you'll need to use an external tool or library to merge the audio from your original video with the processed video. Libraries like moviepy can be very handy for this purpose:

from moviepy.editor import VideoFileClip

original_video = VideoFileClip("input_video_with_audio.mp4")
processed_video = VideoFileClip("processed_video.mp4").set_audio(original_video.audio)
processed_video.write_videofile("final_output_with_audio.mp4")

This snippet takes the audio from your original video and adds it to your YOLOv5 processed video output, saving it as a new file.

I hope this helps! If you have more questions, feel free to ask.