Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
SohamTilekar committed Apr 1, 2024
1 parent aec97df commit 925a131
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 0 deletions.
Empty file added _c_vidiopy/Clip.py
Empty file.
Empty file added _c_vidiopy/_cpp/AudioClip.cpp
Empty file.
Empty file added _c_vidiopy/_cpp/Clip.cpp
Empty file.
Empty file added _c_vidiopy/_cpp/VideoClip.cpp
Empty file.
29 changes: 29 additions & 0 deletions _c_vidiopy/_cpp/vidiopy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#ifdef _WIN32
#define SHARED_EXPORT_API __declspec(dllexport)
#else
#define SHARED_EXPORT_API
#endif

#include <functional>
#include <vector>

class Clip
{
public:
double start;
double end;
double duration;
double fps;
char *name;
std::vector<std::function<double(double)>> time_transforms;
};

class AudioClip : public Clip
{
};

class VideoClip : public Clip
{
};
68 changes: 68 additions & 0 deletions _c_vidiopy/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""This module manages the configuration of ffmpeg and ffprobe binaries."""

import os
from typing_extensions import Union
import ffmpegio

__all__ = ["FFMPEG_BINARY", "FFPROBE_BINARY", "set_path"]

FFMPEG_BINARY = None
FFPROBE_BINARY = None

try:
try:
FFMPEG_BINARY = ffmpegio.get_path()
FFPROBE_BINARY = ffmpegio.get_path(probe=True)
except Exception:
ffmpegio.set_path(os.path.join(__file__, "binary"))
except Exception:
try:
if os.path.exists(
os.path.join(os.path.expanduser("~"), " ffmpeg", "ffmpeg")
) and os.path.exists(
os.path.join(os.path.expanduser("~"), " ffmpeg", "ffprobe")
):
ffmpegio.set_path(os.path.join(os.path.expanduser("~"), " ffmpeg"))
FFMPEG_BINARY = os.path.join(os.path.expanduser("~"), " ffmpeg", "ffmpeg")
FFPROBE_BINARY = os.path.join(
os.path.expanduser("~"), " ffmpeg", "ffprobe"
)
elif os.path.exists(
os.path.join(os.path.expanduser("~"), "ffmpeg", "ffmpeg.exe")
) and os.path.exists(
os.path.join(os.path.expanduser("~"), "ffmpeg", "ffprobe.exe")
):
ffmpegio.set_path(os.path.join(os.path.expanduser("~"), "ffmpeg"))
FFMPEG_BINARY = os.path.join(os.path.expanduser("~"), "ffmpeg", "ffmpeg")
FFPROBE_BINARY = os.path.join(os.path.expanduser("~"), "ffmpeg", "ffprobe")
else:
...
except Exception:
...


def set_path(
ffmpeg_path: Union[str, None] = None, ffprobe_path: Union[str, None] = None
):
"""
Sets the paths for the ffmpeg and ffprobe binaries.
This function sets the paths for the ffmpeg and ffprobe binaries in the global variables FFMPEG_BINARY and FFPROBE_BINARY.
If the paths are not provided, it uses the default paths set in the ffmpegio library.
Parameters:
ffmpeg_path (str | None): The path to the ffmpeg binary. If None, the default ffmpeg path is used.
ffprobe_path (str | None): The path to the ffprobe binary. If None, the default ffprobe path is used.
Returns:
tuple: A tuple containing the paths to the ffmpeg and ffprobe binaries.
Raises:
RuntimeError: If Failed to auto-detect ffmpeg and ffprobe executable.
ValueError: If the given paths are not valid.
"""
global FFMPEG_BINARY, FFPROBE_BINARY
ffmpegio.set_path(ffmpeg_path, ffprobe_path)
FFMPEG_BINARY = ffmpegio.get_path()
FFPROBE_BINARY = ffmpegio.get_path(probe=True)
return FFMPEG_BINARY, FFPROBE_BINARY

0 comments on commit 925a131

Please sign in to comment.