From f6639c87ed008356496a8fdbc0c6ae54c87ff617 Mon Sep 17 00:00:00 2001 From: David Tippett <17506770+dtaivpp@users.noreply.github.com> Date: Wed, 7 Oct 2020 09:29:41 -0400 Subject: [PATCH 1/6] created requirements, and ignoring a tmp folder --- .gitignore | 3 +++ requirements.txt | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 894a44c..729e9c7 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ venv.bak/ # mypy .mypy_cache/ + +# Ignore output files +fvid_frames/ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7aa7962 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +numpy +bitstring +pillow +ffmpeg-python +python-magic +tqdm \ No newline at end of file From ee078031e0d9b0258cad3f3c06eb03baab7ec9bf Mon Sep 17 00:00:00 2001 From: David Tippett <17506770+dtaivpp@users.noreply.github.com> Date: Wed, 7 Oct 2020 10:19:45 -0400 Subject: [PATCH 2/6] Fixed #8 Output file naming not working correctly --- fvid.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/fvid.py b/fvid.py index 9a68f12..65d11e6 100644 --- a/fvid.py +++ b/fvid.py @@ -115,8 +115,15 @@ def save_bits_to_file(filepath, bits): mime = Magic(mime=True) mime_type = mime.from_buffer(bitstring.tobytes()) + # If filepath not passed in use defualt + # otherwise used passed in filepath + if file_path == None: + filepath = f"file{mimetypes.guess_extension(type=mime_type)}" + else: + filepath = file_path + with open( - f"{filepath}/file{mimetypes.guess_extension(type=mime_type)}", "wb" + filepath, "wb" ) as f: bitstring.tofile(f) @@ -158,12 +165,18 @@ def make_image_sequence(bitstring, resolution=(1920, 1080)): def make_video(output_filepath, image_sequence): + if output_filepath == None: + outputfile = "file.mp4" + else: + outputfile = output_filepath + + frames = glob.glob(f"{FRAMES_DIR}encoded_frames*.png") # for one frame if len(frames) == 1: ffmpeg.input(frames[0], loop=1, t=1).output( - output_filepath, vcodec="libx264rgb" + outputfile, vcodec="libx264rgb" ).run(quiet=True) else: @@ -171,7 +184,7 @@ def make_video(output_filepath, image_sequence): f"{FRAMES_DIR}encoded_frames*.png", pattern_type="glob", framerate="1/5", - ).output(output_filepath, vcodec="libx264rgb").run(quiet=True) + ).output(outputfile, vcodec="libx264rgb").run(quiet=True) def cleanup(): @@ -208,14 +221,12 @@ if __name__ == "__main__": if args.decode: bits = get_bits_from_video(args.input) - file_path = "" + file_path = None if args.output: file_path = args.output - else: - file_path = "./" - save_bits_to_file("./", bits) + save_bits_to_file(file_path, bits) elif args.encode: # get bits from file @@ -230,12 +241,10 @@ if __name__ == "__main__": f"{FRAMES_DIR}encoded_frames_{index}.png" ) - video_file_path = "" + video_file_path = None if args.output: video_file_path = args.output - else: - video_file_path = "./file.mp4" make_video(video_file_path, image_sequence) From 312bff2836a483836d0f4f874552dd4482d252a6 Mon Sep 17 00:00:00 2001 From: David Tippett <17506770+dtaivpp@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:25:10 -0400 Subject: [PATCH 3/6] Delete requirements.txt --- requirements.txt | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7aa7962..0000000 --- a/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -numpy -bitstring -pillow -ffmpeg-python -python-magic -tqdm \ No newline at end of file From bfb7f125fcc097e32e80e7eb39833e197dab4df4 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 7 Oct 2020 13:42:01 -0700 Subject: [PATCH 4/6] updated installation instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1083e2e..0b49f38 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ to survive compression algorithms for data retrieval. # Installation -Requires installation of [FFmpeg](https://ffmpeg.org/download.html) first, then install using pip3 +Requires installation of [FFmpeg](https://ffmpeg.org/download.html) and libmagic first, then install using pip3 Linux/macOS From b8c751186a64f727867e62cc963c61d896a2db36 Mon Sep 17 00:00:00 2001 From: David Tippett <17506770+dtaivpp@users.noreply.github.com> Date: Wed, 7 Oct 2020 19:47:50 -0400 Subject: [PATCH 5/6] Updated function definition for save bits to file --- fvid/fvid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fvid/fvid.py b/fvid/fvid.py index 93d0f1a..0748ddb 100644 --- a/fvid/fvid.py +++ b/fvid/fvid.py @@ -107,7 +107,7 @@ def get_bits_from_video(video_filepath): return bits -def save_bits_to_file(filepath, bits): +def save_bits_to_file(file_path, bits): # get file extension bitstring = Bits(bin=bits) From 951605a8f4863e5504bfb596319d78796d3089af Mon Sep 17 00:00:00 2001 From: AlfredoSequeida Date: Wed, 7 Oct 2020 18:04:57 -0700 Subject: [PATCH 6/6] Added demo video --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0b49f38..2a037e7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ -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. - [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity) [![PyPI license](https://img.shields.io/pypi/l/ansicolortags.svg)](https://pypi.python.org/pypi/ansicolortags/) +[Demonstration/Explanation Video](https://youtu.be/yu_ZIr0q5rU) + +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. +

fvid
@@ -69,4 +71,4 @@ py -m fvid -i [input video] -d 3. Write a test which shows that the bug was fixed or that the feature works as expected. 4. Send a pull request and bug the maintainer until it gets merged and - published. :) \ No newline at end of file + published. :)