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

solving #69 - shorten video #70

Merged
merged 4 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added support for --shorten command to resolve Issue #69
  • Loading branch information
supRy committed Sep 15, 2019
commit cdb3c70d9b0875aee6762c64186b8285267a9cc8
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Usage
[--monitor_trigger MONITOR_TRIGGER]
[--check_for_update] [--no-check_for_update]
[--include_test]
[--shorten]
[source [source ...]]

tesla_dashcam - Tesla DashCam & Sentry Video Creator
Expand Down Expand Up @@ -219,6 +220,9 @@ Usage
https://developer.nvidia.com/video-encode-decode-gpu-support-matrix (default: False)
--ffmpeg FFMPEG Path and filename for ffmpeg. Specify if ffmpeg is not
within path. (default: tesla_dashcam/ffmpeg)
--shorten Shorten video by removing duplicate frames. This can reduce video length without slicing the video to certain timestamps. Reduction of
video length will vary based on video content and be as much as 95% (30 second video from 10 minute clip).


Timestamp:
Options for timestamp:
Expand Down
16 changes: 14 additions & 2 deletions tesla_dashcam/tesla_dashcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,12 +1206,15 @@ def create_movie(clips_list, movie_filename, video_settings, chapter_offset):
"1",
"-map_chapters",
"1",
"-c",
"copy",
]
if video_settings["movflags_faststart"]:
ffmpeg_params = ffmpeg_params + ["-movflags", "+faststart"]

if video_settings["shorten"]:
ffmpeg_params = ffmpeg_params + ["-vf","mpdecimate,setpts=N/FRAME_RATE/TB"]
else:
ffmpeg_params = ffmpeg_params + ["-c","copy"]

ffmpeg_command = (
[video_settings["ffmpeg_exec"]] + ffmpeg_params + ["-y", movie_filename]
)
Expand Down Expand Up @@ -1713,6 +1716,7 @@ def main() -> None:
parser.add_argument(
"--version", action="version", version=" %(prog)s " + VERSION_STR
)

parser.add_argument(
"source",
type=str,
Expand Down Expand Up @@ -1838,6 +1842,13 @@ def main() -> None:
"980x380)\n",
)

parser.add_argument(
"--shorten",
dest="shorten",
action="store_true",
help="Shorten video by removing duplicate frames.",
)

mirror_or_rear = parser.add_mutually_exclusive_group()

mirror_or_rear.add_argument(
Expand Down Expand Up @@ -2586,6 +2597,7 @@ def main() -> None:
"start_offset": start_offset,
"end_timestamp": end_timestamp,
"end_offset": end_offset,
"shorten":args.shorten,
}

# If we constantly run and monitor for drive added or not.
Expand Down