Javicle - a JSON Video Composition Language
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

README.md 8.4 KiB

4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. # Javicle - a JSON Video Composition Language
  2. JVCL (pronounced "Javicle") is a JSON DSL for audio/video transformations.
  3. Under the hood, it's all shell commands: `ffmpeg`, `mediainfo`, `sox`, and so on.
  4. JVCL provides higher-level semantics for working with these lower level tools.
  5. # A Quick Example
  6. Say you want to split a portion of a video into ten-second chunks. With ffmpeg
  7. and bash, you might do something like this:
  8. ```shell script
  9. INCR=10
  10. for ((i=10;i<130;i=(i+INCR))); do
  11. ffmpeg -i /tmp/my/source.mp4 -ss ${i} -t $((i+INCR)) /tmp/my/slice_${i}_$((i+INCR)).mp4
  12. done
  13. ```
  14. With JVCL, you'd write this spec file and save it to a file (for example `my-spec.jvcl`):
  15. ```json
  16. {
  17. "assets": [ {"name": "src", "path": "/tmp/my/source.mp4"} ],
  18. "operations": [{
  19. "operation": "split",
  20. "creates": "src_split_files",
  21. "split": "src",
  22. "interval": "10s",
  23. "start": "10s",
  24. "end": "130s"
  25. }]
  26. }
  27. ```
  28. and then run it like this:
  29. ```shell script
  30. jvcl my-spec.jvcl
  31. ```
  32. Yes, the JVCL is longer, but I think many would agree it is easier to read and maintain.
  33. **As the number of input assets and operations grows, hand-crafted shell scripts with magical
  34. ffmpeg incantations become ever more inscrutable.**
  35. JVCL is designed for readability and maintainability. JVCL will continue to evolve towards greater
  36. coverage of the full capabilities of ffmpeg. We also plan to introduce "function" concepts
  37. to create reusable compound operations, further increasing reusability and lowering long-term
  38. maintenance.
  39. # Who is JVCL not for?
  40. If you like GUIs, JVCL is probably not for you.
  41. JVCL is not a replacement for Final Cut Pro or even iMovie.
  42. # Who is JVCL for?
  43. JVCL is for people who like CLIs and automation.
  44. JVCL is for people with relatively simple video composition needs (for now),
  45. since the range of operations supported is limited.
  46. # Concepts
  47. In JVCL there are a few main concepts: spec files, assets and operations.
  48. ## JVCL Spec Files
  49. A JVCL spec file is just a regular JSON file that happens to contain a single JSON object,
  50. whose properties are `assets` and `operations`.
  51. When you run `jvcl` on a spec file, it will load the `assets`, then perform the `operations` in order.
  52. Unlike most JSON, comments *are* allowed in JVCL spec files:
  53. * A line comment starts with `//` and continue to the end of the line
  54. * A multi-line block syntax starts with `/*` and ends with `*/`
  55. ### Executing a JVCL Spec
  56. To execute a spec stored in the file `my-spec.json`, you would run:
  57. ```shell script
  58. jvcl my-spec.jvcl
  59. ```
  60. #### Scratch Directory
  61. Output assets will be placed in the scratch directory, unless otherwise specified
  62. in the spec file. By default, JVCL will create a new temporary directory to use as the scratch
  63. directory. You can set the scratch directory explicitly using the `-t` or `--temp-dir` option:
  64. ```shell script
  65. jvcl -t /some/tempdir my-spec.json
  66. ```
  67. #### Command Help
  68. To view a list of all `jvcl` command-line options, run `jvcl -h` or `jvcl --help`
  69. ## Assets
  70. Assets are your media files: generally image, audio and video files.
  71. All assets have a name and a path.
  72. Input assets are defined using the `assets` array of a JVCL spec.
  73. For input assets, the path can be a file or a URL. URL-based assets will be downloaded
  74. to the scratch directory. This can be overridden using the `dest` property on the asset.
  75. Operations produce one or more output assets, as specified in the `creates` property of
  76. an operation JSON object.
  77. For output assets, the path will be within the scratch directory.
  78. You can override this using the `dest` property on the `creates` object associated with the operation.
  79. ### Asset Properties
  80. Assets expose properties that can be referenced in operations. The properties currently exposed are:
  81. * `duration`: duration of the audio/video in seconds (audio and video assets only)
  82. * `width`: width of the video in pixels (video and image assets only)
  83. * `height`: width of the video in pixels (video and image assets only)
  84. ## Operations
  85. Operations are transformations to perform on the inputs.
  86. An operation can produce one or more new assets, which can then be referenced in
  87. later operations.
  88. Most of the operation settings can be JavaScript expressions, for example:
  89. "start": "someAsset.duration - 10"
  90. The above would set the `start` value to ten seconds before the end of `someAsset`.
  91. ### Supported Operations
  92. Today, JVCL supports these operations:
  93. ### split
  94. Split an audio/video asset into multiple assets
  95. ### concat
  96. Concatenate audio/video assets together into one asset
  97. ### trim
  98. Trim audio/video; crop a section of an asset, becomes a new asset
  99. ### overlay
  100. Overlay one audio or video file onto another
  101. ### ken-burns
  102. For transforming still images into video via a fade-pan (aka Ken Burns) effect
  103. ### letterbox
  104. Transform a video in one size to another size using black letterboxes on the sides or top/bottom. Handy for embedding mobile videos into other screen formats
  105. ### split-silence
  106. Split an audio file according to silence
  107. # Complex Example
  108. Here is a complex example using multiple assets and operations.
  109. ```json
  110. {
  111. "assets": [
  112. // file -- will be referenced directory
  113. {
  114. "name": "vid1",
  115. "path": "/tmp/path/to/video1.mp4"
  116. },
  117. // URL -- will be downloaded to scratch directory and referenced from there
  118. {
  119. "name": "vid2",
  120. "path": "https://archive.org/download/gov.archives.arc.1257628/gov.archives.arc.1257628_512kb.mp4"
  121. },
  122. // URL -- will be downloaded to `dest` directory and referenced from there
  123. {
  124. "name": "vid3",
  125. "path": "https://archive.org/download/gov.archives.arc.49442/gov.archives.arc.49442_512kb.mp4",
  126. "dest": "src/test/resources/sources/"
  127. }
  128. ],
  129. "operations": [
  130. {
  131. "operation": "split", // name of the operation,
  132. "creates": "vid1_split_%", // assets it creates, the '%' will be replaced with a counter
  133. "split": "vid1", // split this source asset
  134. "interval": "10" // split every ten seconds
  135. },
  136. {
  137. "operation": "concat", // name of the operation,
  138. "creates": "recombined_vid1", // assets it creates, the '%' will be replaced with a counter
  139. "concat": ["vid1_split"] // recombine all split assets
  140. },
  141. {
  142. "operation": "concat", // name of the operation,
  143. "creates": "combined_vid", // asset it creates, can be referenced later
  144. "concat": ["vid1", "vid2"] // operation-specific: this says, concatenate these named assets
  145. },
  146. {
  147. "operation": "concat", // name of the operation,
  148. "creates": "combined_vid", // the asset it creates, can be referenced later
  149. "concat": ["vid1", "vid2"] // operation-specific: this says, concatenate these named assets
  150. },
  151. {
  152. "operation": "overlay", // name of the operation,
  153. "creates": {
  154. "name": "overlay1", // asset it creates
  155. "width": "1920", // output width in pixels. default is source width
  156. "height": "1024" // output height in pixes. default is source height
  157. },
  158. "main": "combined_vid1", // main video asset
  159. "start": "30", // when (on the main video timeline) to begin showing the overlay. default is 0 (beginning)
  160. "end": "60", // when (on the main video timeline) to stop showing the overlay. default is to play the entire overlay
  161. "overlay": {
  162. "source": "vid2", // overlay this video on the main video
  163. "start": "0", // when (on the overlay video timeline) to begin playback on the overlay. default is 0 (beginning)
  164. "end": "overlay.duration", // when (on the overlay video timeline) to end playback on the overlay. default is to play the entire overlay
  165. "width": "overlay.width / 2", // how wide the overlay will be, in pixels. default is the full overlay width, or maintain aspect ratio if height was set
  166. "height": "source.height", // how tall the overlay will be, in pixels. default is the full overlay height, or maintain aspect ratio if width was set
  167. "x": "source.width / 2", // horizontal overlay position on main video. default is 0
  168. "y": "source.height / 2" // vertical overlay position on main video. default is 0
  169. }
  170. }
  171. ]
  172. }
  173. ```
  174. ## What's up with the name?
  175. I dunno, a cross between a javelin and an icicle? does that have any positive connotations? ok then...