mirror of https://github.com/AlfredoSequeida/fvid
commit
deffc3eac8
|
@ -0,0 +1,23 @@
|
|||
__Planned (1.1.0)__
|
||||
- GUI
|
||||
|
||||
__1.0.1__
|
||||
- Framerate patch
|
||||
- Further Cython/Python speedups
|
||||
|
||||
__1.0.0__
|
||||
- Added support for passwords, custom framerates, and Cython compilation
|
||||
- file.mp4 compression with ``gzip``
|
||||
- Pickled data to allow decompression with original file name
|
||||
- Fixed ``file.bin`` bug
|
||||
- Removed ``magic``, ``mime``
|
||||
- New ``make_image_sequence`` logic
|
||||
- Huge Cython/Python speedups
|
||||
|
||||
|
||||
__0.0.2__
|
||||
- Bug fixes
|
||||
- Minor speedups
|
||||
|
||||
__0.0.1__
|
||||
- Initial release
|
|
@ -1,2 +1,2 @@
|
|||
__version__ = "1.0.0"
|
||||
__version__ = "1.0.1"
|
||||
|
||||
|
|
35
fvid/fvid.py
35
fvid/fvid.py
|
@ -81,23 +81,16 @@ def get_bits_from_file(filepath, key):
|
|||
bitarray = BitArray(zip)
|
||||
return bitarray.bin
|
||||
|
||||
def less(val1, val2):
|
||||
return val1 < val2
|
||||
|
||||
def get_bits_from_image(image):
|
||||
|
||||
if use_cython:
|
||||
bits = cy_gbfi(image)
|
||||
return bits, False
|
||||
return bits
|
||||
|
||||
width, height = image.size
|
||||
|
||||
done = False
|
||||
|
||||
px = image.load()
|
||||
bits = ""
|
||||
|
||||
white = (255, 255, 255)
|
||||
black = (0, 0, 0)
|
||||
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
|
@ -106,23 +99,16 @@ def get_bits_from_image(image):
|
|||
|
||||
pixel_bin_rep = "0"
|
||||
|
||||
# for exact matches
|
||||
if pixel == white:
|
||||
# if the white difference is smaller, that means the pixel is closer
|
||||
# to white, otherwise, the pixel must be black
|
||||
if abs(pixel[0] - 255) < abs(pixel[0] - 0) and abs(pixel[1] - 255) < abs(pixel[1] - 0) and abs(pixel[2] - 255) < abs(pixel[2] - 0):
|
||||
pixel_bin_rep = "1"
|
||||
elif pixel == black:
|
||||
pixel_bin_rep = "0"
|
||||
else:
|
||||
# if the white difference is smaller, that means the pixel is closer
|
||||
# to white, otherwise, the pixel must be black
|
||||
if abs(pixel[0] - 255) < abs(pixel[0] - 0) and abs(pixel[1] - 255) < abs(pixel[1] - 0) and abs(pixel[2] - 255) < abs(pixel[2] - 0):
|
||||
pixel_bin_rep = "1"
|
||||
else:
|
||||
pixel_bin_rep = "0"
|
||||
|
||||
# adding bits
|
||||
bits += pixel_bin_rep
|
||||
|
||||
return (bits, done)
|
||||
return bits
|
||||
|
||||
|
||||
def get_bits_from_video(video_filepath):
|
||||
# get image sequence from video
|
||||
|
@ -141,12 +127,7 @@ def get_bits_from_video(video_filepath):
|
|||
if use_cython:
|
||||
print('Using Cython...')
|
||||
for index in tqdm(range(sequence_length)):
|
||||
b, done = get_bits_from_image(image_sequence[index])
|
||||
|
||||
bits += b
|
||||
|
||||
if done:
|
||||
break
|
||||
bits += get_bits_from_image(image_sequence[index])
|
||||
|
||||
return bits
|
||||
|
||||
|
|
|
@ -19,18 +19,10 @@ cpdef str cy_get_bits_from_image(image):
|
|||
|
||||
pixel_bin_rep = <str>"0"
|
||||
|
||||
# for exact matches, indexing each pixel individually is faster in cython for some reason
|
||||
if pixel[0] == 255 and pixel[1] == 255 and pixel[2] == 255:
|
||||
# if the white difference is smaller (comparison part 1), that means the pixel is closer
|
||||
# to white, otherwise, the pixel must be black
|
||||
if abs(pixel[0] - 255) < abs(pixel[0] - 0) and abs(pixel[1] - 255) < abs(pixel[1] - 0) and abs(pixel[2] - 255) < abs(pixel[2] - 0):
|
||||
pixel_bin_rep = <str>"1"
|
||||
elif pixel[0] == 0 and pixel[1] == 0 and pixel[2] == 0:
|
||||
pixel_bin_rep = <str>"0"
|
||||
else:
|
||||
# if the white difference is smaller (comparison part 1), that means the pixel is closer
|
||||
# to white, otherwise, the pixel must be black
|
||||
if abs(pixel[0] - 255) < abs(pixel[0] - 0) and abs(pixel[1] - 255) < abs(pixel[1] - 0) and abs(pixel[2] - 255) < abs(pixel[2] - 0):
|
||||
pixel_bin_rep = <str>"1"
|
||||
else:
|
||||
pixel_bin_rep = <str>"0"
|
||||
|
||||
# adding bits
|
||||
bits += pixel_bin_rep
|
||||
|
|
150
setup.py
150
setup.py
|
@ -2,7 +2,7 @@ import os
|
|||
import codecs
|
||||
from setuptools import setup
|
||||
from setuptools import Extension
|
||||
from setuptools.command.build_ext import build_ext as _build_ext
|
||||
from setuptools.command.build_ext import build_ext
|
||||
|
||||
try:
|
||||
from Cython.Build import cythonize
|
||||
|
@ -13,16 +13,14 @@ else:
|
|||
use_cython = True
|
||||
ext = 'pyx'
|
||||
|
||||
if not use_cython:
|
||||
extensions = Extension("fvid.fvid_cython", ["fvid/fvid_cython.c"], include_dirs=["./fvid", "fvid/"])
|
||||
else:
|
||||
extensions = Extension("fvid.fvid_cython", ["fvid/fvid_cython.pyx"], include_dirs=["./fvid", "fvid/"])
|
||||
extensions = cythonize(extensions, compiler_directives={'language_level': "3", 'infer_types': True})
|
||||
|
||||
|
||||
class build_ext(_build_ext):
|
||||
def finalize_options(self):
|
||||
_build_ext.finalize_options(self)
|
||||
try:
|
||||
if not use_cython:
|
||||
extensions = [Extension("fvid.fvid_cython", ["fvid/fvid_cython.c"], include_dirs=["./fvid", "fvid/"])]
|
||||
else:
|
||||
extensions = [Extension("fvid.fvid_cython", ["fvid/fvid_cython.pyx"], include_dirs=["./fvid", "fvid/"])]
|
||||
extensions = cythonize(extensions, compiler_directives={'language_level': "3", 'infer_types': True})
|
||||
except: # blanket exception until the exact exception name is found
|
||||
extensions = []
|
||||
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
@ -45,48 +43,88 @@ def get_version(rel_path):
|
|||
|
||||
dynamic_version = get_version("fvid/__init__.py")
|
||||
|
||||
setup(
|
||||
name="fvid",
|
||||
version=dynamic_version,
|
||||
author="Alfredo Sequeida",
|
||||
description="fvid is a project that aims to encode any file as a video using 1-bit color images to survive compression algorithms for data retrieval.",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/AlfredoSequeida/fvid",
|
||||
download_url="https://github.com/AlfredoSequeida/fvid/archive/"
|
||||
+ dynamic_version
|
||||
+ ".tar.gz",
|
||||
keywords="fvid youtube videos files bitdum hexdump ffmpeg video file",
|
||||
platforms="any",
|
||||
classifiers=[
|
||||
"Intended Audience :: End Users/Desktop",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Operating System :: Microsoft :: Windows :: Windows 10",
|
||||
"Operating System :: Microsoft :: Windows :: Windows 8",
|
||||
"Operating System :: Microsoft :: Windows :: Windows 8.1",
|
||||
"Operating System :: MacOS :: MacOS X",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
],
|
||||
license="MIT",
|
||||
packages=["fvid"],
|
||||
setup_requires=[
|
||||
"cython >= 3.0a6"
|
||||
],
|
||||
install_requires=[
|
||||
"bitstring",
|
||||
"pillow",
|
||||
"tqdm",
|
||||
"cryptography >= 3.1.1",
|
||||
"pycryptodome >= 3.9.8"
|
||||
],
|
||||
python_requires=">=3.6",
|
||||
entry_points={"console_scripts": ["fvid = fvid.fvid:main"]},
|
||||
ext_modules=extensions,
|
||||
cmdclass={'build_ext': build_ext},
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
)
|
||||
try:
|
||||
setup(
|
||||
name="fvid",
|
||||
version=dynamic_version,
|
||||
author="Alfredo Sequeida",
|
||||
description="fvid is a project that aims to encode any file as a video using 1-bit color images to survive compression algorithms for data retrieval.",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/AlfredoSequeida/fvid",
|
||||
download_url="https://github.com/AlfredoSequeida/fvid/archive/"
|
||||
+ dynamic_version
|
||||
+ ".tar.gz",
|
||||
keywords="fvid youtube videos files bitdum hexdump ffmpeg video file",
|
||||
platforms="any",
|
||||
classifiers=[
|
||||
"Intended Audience :: End Users/Desktop",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Operating System :: Microsoft :: Windows :: Windows 10",
|
||||
"Operating System :: Microsoft :: Windows :: Windows 8",
|
||||
"Operating System :: Microsoft :: Windows :: Windows 8.1",
|
||||
"Operating System :: MacOS :: MacOS X",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
],
|
||||
license="MIT",
|
||||
packages=["fvid"],
|
||||
install_requires=[
|
||||
"bitstring >= 3.1.6",
|
||||
"pillow >= 7.2.0",
|
||||
"tqdm >= 4.49.0",
|
||||
"cryptography >= 3.1.1",
|
||||
"pycryptodome >= 3.9.8"
|
||||
],
|
||||
python_requires=">=3.6",
|
||||
entry_points={"console_scripts": ["fvid = fvid.fvid:main"]},
|
||||
cmdclass={'build_ext': build_ext},
|
||||
ext_modules=extensions,
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
)
|
||||
except:
|
||||
setup(
|
||||
name="fvid",
|
||||
version=dynamic_version,
|
||||
author="Alfredo Sequeida",
|
||||
description="fvid is a project that aims to encode any file as a video using 1-bit color images to survive compression algorithms for data retrieval.",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/AlfredoSequeida/fvid",
|
||||
download_url="https://github.com/AlfredoSequeida/fvid/archive/"
|
||||
+ dynamic_version
|
||||
+ ".tar.gz",
|
||||
keywords="fvid youtube videos files bitdum hexdump ffmpeg video file",
|
||||
platforms="any",
|
||||
classifiers=[
|
||||
"Intended Audience :: End Users/Desktop",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Operating System :: Microsoft :: Windows :: Windows 10",
|
||||
"Operating System :: Microsoft :: Windows :: Windows 8",
|
||||
"Operating System :: Microsoft :: Windows :: Windows 8.1",
|
||||
"Operating System :: MacOS :: MacOS X",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
],
|
||||
license="MIT",
|
||||
packages=["fvid"],
|
||||
install_requires=[
|
||||
"bitstring >= 3.1.6",
|
||||
"pillow >= 7.2.0",
|
||||
"tqdm >= 4.49.0",
|
||||
"cryptography >= 3.1.1",
|
||||
"pycryptodome >= 3.9.8"
|
||||
],
|
||||
python_requires=">=3.6",
|
||||
entry_points={"console_scripts": ["fvid = fvid.fvid:main"]},
|
||||
include_package_data=True,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue