{"id":39070175,"url":"https://github.com/monocongo/video_utils","last_synced_at":"2026-01-17T18:20:07.383Z","repository":{"id":97693444,"uuid":"186464362","full_name":"monocongo/video_utils","owner":"monocongo","description":"Video clip extraction and storage to AWS S3 buckets using boto3","archived":false,"fork":false,"pushed_at":"2019-06-22T00:54:47.000Z","size":40,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-11T19:52:50.357Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monocongo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-05-13T17:16:06.000Z","updated_at":"2019-06-11T21:16:35.000Z","dependencies_parsed_at":"2023-03-30T20:33:15.878Z","dependency_job_id":null,"html_url":"https://github.com/monocongo/video_utils","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"c1fd5d0041294f91b498f2878029723377fe6f66"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/monocongo/video_utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monocongo%2Fvideo_utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monocongo%2Fvideo_utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monocongo%2Fvideo_utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monocongo%2Fvideo_utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monocongo","download_url":"https://codeload.github.com/monocongo/video_utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monocongo%2Fvideo_utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28515299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T17:57:59.192Z","status":"ssl_error","status_checked_at":"2026-01-17T17:57:52.527Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-17T18:20:04.580Z","updated_at":"2026-01-17T18:20:07.326Z","avatar_url":"https://github.com/monocongo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# video_utils\n\n## Deploy RESTful API for video clip extraction to MP4 and storage to AWS S3\n\nLogin to the Amazon EC2 instance with `ssh` using the appropriate `*.pem` key file \nand public IP address (`52.15.182.126` in this example):\n```\n$ ssh -i ~/.ssh/aws_keys/james.pem ubuntu@52.15.182.126\n```\n\nUpdate and upgrade Ubuntu packages and install `ffmpeg`:\n```\n$ sudo apt update\n$ sudo apt upgrade\n$ sudo apt install ffmpeg\n```\n\nCreate an Anaconda environment by downloading the Miniconda package for Linux, \nrunning the installer, and adding the required modules:\n```\n$ chmod +x Miniconda3-latest-Linux-x86_64.sh\n$ ./Miniconda3-latest-Linux-x86_64.sh\n$ rm Miniconda3-latest-Linux-x86_64.sh\n\n(Log out and back in to make the changes take effect)\n\n$ conda config --set auto_activate_base false\n\n(Log out and back in to make the changes take effect)\n\n$ conda create -n mp4_to_s3 python=3.7 boto flask\n$ conda activate mp4_to_s3\n$ pip install ffmpeg-python\n```\n\nClone this repository. NOTE: This will probably require adding an SSH key to the \nrepository for this EC2 instance, described \n[here](https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).\n```\n$ mkdir ~/git\n$ cd ~/git\n$ git clone git@github.com:SecurityCameraWarehouse/video_utils.git\n```\n\nSet the `PYTHONPATH` environment variable to the `~/git/video_utils` directory:\n```\n$ cd ~/git/video_utils\n$ export PYTHONPATH=`pwd`\n```\n\nAdd AWS credentials and configuration information relevant to the S3 bucket(s) \nwhere we'll be storing the MP4 clips:\n```\n$ mkdir ~/.aws\n$ echo \"[default]\n\u003e aws_access_key_id = AWS_ACCESS_KEY_ID\n\u003e aws_secret_access_key = AWS_SECRET_ACCESS_KEY\" \u003e\u003e ~/.aws/credentials\n$ echo \"[default]\nregion=us-east-2\" \u003e\u003e ~/.aws/config\n```\n\nIn order to run the application on port 80 we'll need to run the Flask application \nwith `sudo` (this is a current requirement until we can work out how to configure \nsecurity group rules to allow for inbound traffic to port 5000). For this to work\nwe'll need to set the environment variables `PYTHONPATH`, `AWS_SHARED_CREDENTIALS_FILE`, \nand `AWS_CONFIG_FILE`, as well as specifically referencing the path to the Python \ninterpreter of the conda environment. We'll also run the command using `nohup` in \norder to prevent the application from terminating if we log out of the shell, and \nwe redirect standard error and output to a log file:\n```\n$ nohup sudo -HE env PYTHONPATH=$PYTHONPATH AWS_SHARED_CREDENTIALS_FILE=/home/ubuntu/.aws/credentials AWS_CONFIG_FILE=/home/ubuntu/.aws/config /home/ubuntu/miniconda3/envs/mp4_to_s3/bin/python /home/ubuntu/git/video_utils/video_utils/restful_api.py --port 80  2\u003e\u00261 \u003e\u003e ~/restful_api_mp4_to_s3.log \u0026\n```\n\nNow the application should be available via port 80. We can test from another \n(remote) machine for a simple \"hello\" response as well as the actual/intended usage \nfor triggering an MP4 extraction with storage on an S3 bucket which should result \nin the URL to the S3 bucket file for the extracted clip MP4 file: \n```\n$ curl http://52.15.182.126/hello\nHello!\n$ curl http://52.15.182.126/clip?rtsp=rtsp://user:password@171.185.14.155:554\u0026start=1559077593\u0026duration=10\u0026bucket=scw.james.adams\u0026prefix=test\ns3://scw.james.adams/test.clip_b1559077593_e1559077603.mp4\n```\n\n\n\n## Video clip extraction and storage to AWS S3 buckets using boto3\n\n#### Configure user for AWS S3 access\nCreate a credentials file, `~/.aws/credentials`, with the user's access key ID \nand secret access key, and a confguration file, `~/.aws/config`, containing the \ndefault region.\n\n```\n$ cat ~/.aws/credentials\n[default]\naws_access_key_id = SOMEACCESSKEYIDOTHERTHANTHIS\naws_secret_access_key = SECRETACCESSKEYFORTHEUSER\n\n$ cat ~/.aws/config \n[default]\nregion=us-east-3\n\n```\n\n#### Find an existing S3 bucket\n```\n$ python\n\u003e\u003e\u003e import boto3\n\u003e\u003e\u003e s3 = boto3.client('s3')\n\u003e\u003e\u003e response = s3.list_buckets()\n\u003e\u003e\u003e s3 = boto3.client('s3')\n\u003e\u003e\u003e response = s3.list_buckets()\n\u003e\u003e\u003e for bucket in response['Buckets']:\n...     print(f'  {bucket[\"Name\"]}')\n... \n  elasticbeanstalk-us-east-2-867324276890\n\u003e\u003e\u003e\n```\n#### Run script\n```\n$ python save_extract.py --source /home/james/video/big_buck_bunny_720p_2mb.mp4 --dest_s3_bucket elasticbeanstalk-us-east-2-867324276890 --dest_s3_key bunny_clip.mp4 --start 2 --end 7\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonocongo%2Fvideo_utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonocongo%2Fvideo_utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonocongo%2Fvideo_utils/lists"}