Skip to content

Commit

Permalink
fix #345 compile readme (#388)
Browse files Browse the repository at this point in the history
* compile readme

* fix #345 compile readme with script

* use direct path
  • Loading branch information
lucemia authored Apr 10, 2024
1 parent 869ee83 commit 2019734
Show file tree
Hide file tree
Showing 7 changed files with 628 additions and 5 deletions.
383 changes: 383 additions & 0 deletions README.ipynb

Large diffs are not rendered by default.

32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ Note: This requires Graphviz to be installed on your system.

Here's how to quickly start using `typed-ffmpeg`:




```python
import ffmpeg

Expand All @@ -80,37 +83,56 @@ f = (
.hflip()
.output(filename='output.mp4')
)
f.run()
f
```

![](https://raw.githubusercontent.com/livingbio/typed-ffmpeg/main/docs/media/quick-usage.png)




![svg](https://raw.githubusercontent.com/livingbio/typed-ffmpeg/main/docs/media/README_files/README_1_0.svg)




For a more complex example:



```python
import ffmpeg.filters
import ffmpeg

# Complex filter graph example
in_file = ffmpeg.input("input.mp4")
overlay_file = ffmpeg.input("overlay.png")

f = (
ffmpeg
ffmpeg.filters
.concat(
in_file.trim(start_frame=10, end_frame=20),
in_file.trim(start_frame=30, end_frame=40),
)
.video(0)
.overlay(overlay_file.hflip())
.drawbox(x="50", y="50", width="120", height="120", color="red", thickness="5")
.output(filename="out.mp4")
)
f.run()
f
```

![](https://raw.githubusercontent.com/livingbio/typed-ffmpeg/main/docs/media/quick-usage-complex.png)




![svg](https://raw.githubusercontent.com/livingbio/typed-ffmpeg/main/docs/media/README_files/README_3_0.svg)




See the [Usage](https://livingbio.github.io/typed-ffmpeg/usage/typed/) section in our documentation for more examples and detailed guides.


---

## Acknowledgements
Expand Down
Binary file added docs/media/README_files/README_1_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions docs/media/README_files/README_1_0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/README_files/README_3_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 130 additions & 0 deletions docs/media/README_files/README_3_0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions scripts/compile-readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import shutil

import typer


def post_process(markdown_file: str, original_folder: str, new_folder: str) -> None:
rel_path = "https://raw.githubusercontent.com/livingbio/typed-ffmpeg/main/" + new_folder

# Move the folder
if os.path.exists(original_folder):
for filepath in os.listdir(original_folder):
# Move the file, replace if it already exists
old_path = os.path.join(original_folder, filepath)
new_path = os.path.join(new_folder, filepath)
if os.path.exists(new_path):
os.remove(new_path)

shutil.move(old_path, new_path)
print(f"Moved {filepath} to {new_folder}")

# Update paths in the Markdown file
with open(markdown_file, "r") as file:
content = file.read()

content = content.replace(original_folder, rel_path)

with open(markdown_file, "w") as file:
file.write(content)

print("Image paths updated and folder moved.")


def main() -> None:
os.remove("README.md")
os.system("jupyter nbconvert --to markdown README.ipynb")
assert os.path.exists("README.md")

post_process("README.md", "README_files", "docs/media/README_files")


if __name__ == "__main__":
typer.run(main)

0 comments on commit 2019734

Please sign in to comment.