Skip to content
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

How to remove audio and video length restrictions? #4

Open
mnbv7758 opened this issue Oct 31, 2024 · 4 comments
Open

How to remove audio and video length restrictions? #4

mnbv7758 opened this issue Oct 31, 2024 · 4 comments
Labels
good first issue Good for newcomers

Comments

@mnbv7758
Copy link

How to remove audio and video length restrictions?

@H-Liu1997
Copy link
Collaborator

H-Liu1997 commented Nov 2, 2024

audio limitation:

TANGO/app.py

Lines 558 to 562 in e24a2f4

resampled_audio = librosa.resample(audio_waveform, orig_sr=sample_rate, target_sr=TARGET_SR)
required_length = int(TARGET_SR * (128 / 30)) * 2
resampled_audio = resampled_audio[:required_length]
sf.write(saved_audio_path, resampled_audio, TARGET_SR)
audio_path = saved_audio_path

video limitiaion:

TANGO/app.py

Lines 479 to 504 in e24a2f4

def save_first_10_seconds(video_path, output_path="./save_video.mp4", max_length=512):
if os.path.exists(output_path):
os.remove(output_path)
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
return
fps = int(cap.get(cv2.CAP_PROP_FPS))
original_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
original_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
# Calculate the aspect ratio and resize dimensions
if original_width >= original_height:
new_width = max_length
new_height = int(original_height * (max_length / original_width))
else:
new_height = max_length
new_width = int(original_width * (max_length / original_height))
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
out = cv2.VideoWriter(output_path.replace(".mp4", "_fps.mp4"), fourcc, fps, (new_width, new_height))
frames_to_save = fps * 20
frame_count = 0

@H-Liu1997 H-Liu1997 added the good first issue Good for newcomers label Nov 2, 2024
@wangaocheng
Copy link

@H-Liu1997 可以把具体要修改的位置和代码告诉我吗?

@tsxxdw
Copy link

tsxxdw commented Nov 11, 2024

1 required_length = int(TARGET_SR * (128 / 30)) * 2
2 frames_to_save = fps* 20
@wangaocheng 改这2行就行了,分别是声音和视频的时长控制。

@dz-star
Copy link

dz-star commented Dec 13, 2024

这里除以30是什么意思?
required_length = int(TARGET_SR * (128 / 30)) * 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants