项目作者: umutseven92

项目描述 :
An automatic movie trailer generator.
高级语言: Python
项目地址: git://github.com/umutseven92/LaFontaine.git
创建时间: 2018-11-26T13:30:35Z
项目社区:https://github.com/umutseven92/LaFontaine

开源协议:MIT License

下载


LaFontaine Build Status Codacy Badge

LaFontaine is an automatic movie trailer generator.

Description

LaFontaine creates movie trailers for any genre using pre-defined features, like number of faces on screen, and loudness of volume.
Scenes are extracted using these features and combined to create the final trailer.
There are three features for frame, three features for sound and three features for subtitles. Features are read from configurations and are fully configurable.

Etymology

LaFontaine is named after the legendary Don LaFontaine, who was the voice of more than 5000 movie trailers.
He is the voice in the classic phrase “In a world…”.

All Features

Image Features

Face Recognizer

  1. {
  2. "id": "FaceRecognizer",
  3. "face_count": 3,
  4. "frames": 100
  5. }

Records for frames amount of frames if the amount of faces in the screen is greater than face_count.

Frame Delta Detector

  1. {
  2. "id": "FrameDeltaDetector",
  3. "delta": 0.95,
  4. "frame_limit": 50,
  5. "scene_change_limit": 3,
  6. "frames": 75
  7. }

Records for frames amount of frames if frame difference percentage is greater than delta at least scene_change_limit times continuously for at least frame_limit frames.

Frame Color Counter

  1. {
  2. "id": "ColorCounter",
  3. "color_count": 50000,
  4. "frames": 100
  5. }

Records for frames amount of frames if the amount of unique colors is greater than color_count.

Sound Features

Sound Peak Detector

  1. {
  2. "id": "SoundPeakDetector",
  3. "audio_threshold": 0.30,
  4. "frames": 50
  5. }

Records for frames amount of frames if the volume is higher than audio_threshold.

High Volume Detector

  1. {
  2. "id": "HighVolumeDetector",
  3. "volume": 0.60,
  4. "frame_limit": 50,
  5. "frames": 70
  6. }

Records for frames amount of frames if the volume is continuously higher than volume for frame_limit amount of frames.

Sound Delta Detector

  1. {
  2. "id": "SoundDeltaDetector",
  3. "delta": 3,
  4. "frame_limit": 50,
  5. "scene_change_limit": 3,
  6. "frames": 75
  7. }

Records for frames amount of frames if audio difference percentage is greater than delta at least scene_change_limit times continuously for at least frame_limit frames.

Subtitle Features

Subtitle Density Detector

  1. {
  2. "id": "SubtitleDensityDetector",
  3. "char_count": 60,
  4. "frames": 100
  5. }

Records for frames amount of frames if the subtitle has more than char_count characters.

Subtitle Intensity Detector

  1. {
  2. "id": "SubtitleIntensityDetector",
  3. "intensity_char": "!",
  4. "char_count": 3,
  5. "frames": 100
  6. }

Records for frames amount of frames if the subtitle has more than char_count intensity_char characters.

Subtitle Conversation Counter

  1. {
  2. "id": "SubtitleConversationCount",
  3. "conversation_count": 2,
  4. "frames": 100
  5. }

Records for frames amount of frames if the subtitle has more than conversation_count characters speaking.

Dependencies

  • Python 3+.
  • ImageMagick is required to create end titles.
  • If CUDA is going to be enabled for better performance, dlib needs to be compiled with CUDA support.

Configuration

Configuration files contain list of features and some other metadata. Each genre has its own configuration file. To create an action movie trailer, you use the action.lf file, to create a comedy movie trailer you use comedy.lf and vice versa.

Example configuration files are given in the res/config/ folder, however you can create your own custom configurations.

res/config/action.lf:

  1. {
  2. "genre": "action",
  3. "max_length": "120",
  4. "features": [
  5. {
  6. "id": "SoundPeakDetector",
  7. "audio_threshold": 0.30,
  8. "frames": 50
  9. },
  10. {
  11. "id": "FrameDeltaDetector",
  12. "delta": 0.95,
  13. "frame_limit": 50,
  14. "scene_change_limit": 3,
  15. "frames": 75
  16. },
  17. {
  18. "id": "HighVolumeDetector",
  19. "volume": 0.60,
  20. "frame_limit": 50,
  21. "frames": 70
  22. },
  23. {
  24. "id": "FaceRecognizer",
  25. "face_count": 3,
  26. "frames": 100
  27. },
  28. {
  29. "id": "SubtitleIntensityDetector",
  30. "intensity_char": "!",
  31. "char_count": 3,
  32. "frames": 100
  33. }
  34. ]
  35. }
Parameter Description Required
genre Name of the genre True
max_length Max length of the trailer in seconds True
features List of features, listed in order of importance True

Usage

  1. python lafontaine.py -f res/videos/northbynorthwest.mp4 -s res/subtitles/northbynorthwest.srt -c res/config/action.lf -t "North by Northwest" -d 480 -cd
Parameter Description Required
-f, —file Path to the video file True
-s, —sub Path to the subtitle file1 False
-o, —output Path to the output file2 False
-c, —config Path to the feature configuration file True
-t, —title What to put on the title card in the end of the trailer False
-d, —downscale Which width to downscale the resolution to3 False
-cd, —cuda Enable CUDA support False
-sp, —spoiler Parse only the first half of the movie to avoid spoilers False

1: If this option is not given, subtitle features will be disabled.

2: If this option is not given, the output will be saved to lafontaine/out/.

3: Aspect ration will be preserved.

Example Trailer