Javicle - a JSON Video Composition Language
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # JVC JavaScript Expressions
  2. JavaScript expressions are used in a couple of places in JVC.
  3. * Operation configuration
  4. * Operation validations
  5. ## Operation Configuration
  6. When you're writing the JSON for an operation, many of the operation's
  7. config parameters can be JS expressions that will be evaluated
  8. when the operation is run.
  9. For example, say you wanted to use `trim` to just chop a video in half.
  10. The `start` and `end` parameters of the `trim` operation support JavaScript
  11. expressions, so you could write:
  12. ```js
  13. {
  14. "comment": "cut video at midpoint",
  15. "operation": "trim",
  16. "creates": "chopped"
  17. "source": "some_vid",
  18. "end": "source.duration / 2"
  19. }
  20. ```
  21. or run:
  22. ```shell script
  23. jtrim some_vid.mp4 output_vid.mp4 0 "source.duration / 2"
  24. ```
  25. In the above, `source` is referring to the source asset, `some_vid`.
  26. When JVC loads an asset (like `some_vid`), or an operation creates a new asset,
  27. the asset metadata is read using `mediainfo`. The metadata is stored in an object
  28. that is then put into the JavaScript context using the variable name `source`.
  29. ## Operation Validations
  30. Once an operation completes, the validations run to ensure that the output
  31. assets pass whatever tests you want to run.
  32. Each test is a JavaScript expressions, which is evaluated to a boolean value.
  33. If the expression is true, the test passes. If false, the test fails and the
  34. `comment` associated with the failing test is printed.
  35. ## JavaScript Context
  36. What variables are available in the JS context? And what properties do they have?
  37. ### Assets
  38. Assets can be defined in the JVC's `assets` array, or as the output of an
  39. operation.
  40. Assets are referenced by their asset name.