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
Optimize hflip #148
Optimize hflip #148
Conversation
Summary: Sometimes `extract_audio_to_file()` only extracts the beginning of an audio clip, not the full one. This issue was identified in Adib (MLH intern)'s [PR](facebookresearch#133) adding `augment_audio` because the audio metadata had a src & dst duration way shorter than that of the video. - Changed the code in `extract_audio_to_file()` to be more like [this example](https://www.kaggle.com/josecarmona/ffmpeg-python-example-to-extract-audio-from-mp4) I found, which seems to work better for wav files - If the audio file is aac format, run the old version of the function (because the new version isn't compatible with aac) Differential Revision: D31378945 fbshipit-source-id: 38543c0a774e24800d7dc00032d3c9e48ffaa0c8
@Adib234 has updated the pull request. You must reimport the pull request before landing. |
@zpapakipos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
||
@abstractmethod | ||
def get_command( | ||
self, video_path: str, output_path: Optional[str] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self, video_path: str, output_path: Optional[str] = None | |
self, video_path: str, output_path: str |
@param video_path: the path to the video to be augmented | ||
|
||
@param output_path: the path in which the resulting video will be stored. | ||
If not passed in, the original video file will be overwritten |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not passed in, the original video file will be overwritten |
) -> Tuple[FilterableStream, Dict]: | ||
class VideoAugmenterByHFlip(BaseVidgearFFMPEGAugmenter): | ||
def get_command( | ||
self, video_path: str, output_path: Optional[str] = None, **kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self, video_path: str, output_path: Optional[str] = None, **kwargs | |
self, video_path: str, output_path: str = None, **kwargs |
@returns: a tuple containing the FFMPEG object with the augmentation | ||
applied and a dictionary with any output arguments as necessary | ||
@param output_path: the path in which the resulting video will be stored. | ||
If not passed in, the original video file will be overwritten |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not passed in, the original video file will be overwritten |
…path and output path
…o optimize-hflip * 'optimize-hflip' of https://github.com/Adib234/AugLy: Update requirements.txt
@Adib234 has updated the pull request. You must reimport the pull request before landing. |
@Adib234 has updated the pull request. You must reimport the pull request before landing. |
@Adib234 has updated the pull request. You must reimport the pull request before landing. |
@Adib234 has updated the pull request. You must reimport the pull request before landing. |
@zpapakipos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@abstractmethod | ||
def get_command(self, video_path: str, output_path: str) -> List[str]: | ||
""" | ||
Constructs the FFMPEG so that VidGear can run it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constructs the FFMPEG so that VidGear can run it | |
Constructs the FFMPEG command for VidGear |
Co-authored-by: Zoe Papakipos <zpapakipos@users.noreply.github.com>
@Adib234 has updated the pull request. You must reimport the pull request before landing. |
@zpapakipos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
the augmentation | ||
in a command line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you remove this extraneous line? :D
the augmentation | |
in a command line | |
the augmentation |
@Adib234 has updated the pull request. You must reimport the pull request before landing. |
@zpapakipos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: - [X ] I have read CONTRIBUTING.md to understand how to contribute to this repository :) <Please summarize what you are trying to achieve, what changes you made, and how they acheive the desired result.> I am trying to speed up horizontally flipping, and what I did is use VidGear to execute an ffmpeg command with the preset of ultrafast. With my changes in running HFlip tests: 4.724 seconds (tests would complete around 2.5 seconds) Without my changes in running HFlip tests: 12.534 seconds (tests would complete around 10.5 seconds) I've run each test with and without my changes five times on fish shell with this command `time for i in (seq 5); python -m unittest augly.tests.video_tests.transforms.ffmpeg_test.TransformsVideoUnitTest.test_HFlip;; end` ## Unit Tests If your changes touch the `audio` module, please run all of the `audio` tests and paste the output here. Likewise for `image`, `text`, & `video`. If your changes could affect behavior in multiple modules, please run the tests for all potentially affected modules. If you are unsure of which modules might be affected by your changes, please just run all the unit tests. ### Audio ```bash python -m unittest discover -s augly/tests/audio_tests/ -p "*" ``` ### Image ```bash python -m unittest discover -s augly/tests/image_tests/ -p "*_test.py" # Or `python -m unittest discover -s augly/tests/image_tests/ -p "*.py"` to run pytorch test too (must install `torchvision` to run) ``` ### Text ```bash python -m unittest discover -s augly/tests/text_tests/ -p "*" ``` ### Video ```bash python -m unittest discover -s augly/tests/video_tests/ -p "*" ``` ### All ```bash python -m unittest discover -s augly/tests/ -p "*" ``` ## Other testing If applicable, test your changes and paste the output here. For example, if your changes affect the requirements/installation, then test installing augly in a fresh conda env, then make sure you are able to import augly & run the unit test Pull Request resolved: facebookresearch#148 Reviewed By: jbitton Differential Revision: D32591542 Pulled By: zpapakipos fbshipit-source-id: 83116e0ffe83c1682c6255ac2f65b58716f088f7
…oise-vflip * upstream/main: Optimize hflip (facebookresearch#148) increasing highpass efficiency (facebookresearch#149)
…34/AugLy into optimize-loop-add_noise-vflip * 'optimize-merge-video-audio' of https://github.com/Adib234/AugLy: (31 commits) Optimize hflip (facebookresearch#148) increasing highpass efficiency (facebookresearch#149) added newline to match upstream main manually changed base_unit_test.py to be in sync with upstream/main Remove ci_testing workflow that I was testing Remove making new conda env Add conda init Fix spaces Use conda Fix python step Merge python & reqs steps Add CI testing Github action added vidgear with version number format with black replaced video_path with output_path removed using the same file path for a ffmpeg command using tempfile instead of actually creating a file added vidgear as a dependency used newer format removed uncommented code ...
…34/AugLy into optimize-merge-video-audio * 'optimize-merge-video-audio' of https://github.com/Adib234/AugLy: (31 commits) Optimize hflip (facebookresearch#148) increasing highpass efficiency (facebookresearch#149) added newline to match upstream main manually changed base_unit_test.py to be in sync with upstream/main Remove ci_testing workflow that I was testing Remove making new conda env Add conda init Fix spaces Use conda Fix python step Merge python & reqs steps Add CI testing Github action added vidgear with version number format with black replaced video_path with output_path removed using the same file path for a ffmpeg command using tempfile instead of actually creating a file added vidgear as a dependency used newer format removed uncommented code ...
Summary
<Please summarize what you are trying to achieve, what changes you made, and how they acheive the desired result.>
I am trying to speed up horizontally flipping, and what I did is use VidGear to execute an ffmpeg command with the preset of ultrafast.
With my changes in running HFlip tests: 4.724 seconds (tests would complete around 2.5 seconds)
Without my changes in running HFlip tests: 12.534 seconds (tests would complete around 10.5 seconds)
I've run each test with and without my changes five times on fish shell with this command
time for i in (seq 5); python -m unittest augly.tests.video_tests.transforms.ffmpeg_test.TransformsVideoUnitTest.test_HFlip;; end
Unit Tests
If your changes touch the
audio
module, please run all of theaudio
tests and paste the output here. Likewise forimage
,text
, &video
. If your changes could affect behavior in multiple modules, please run the tests for all potentially affected modules. If you are unsure of which modules might be affected by your changes, please just run all the unit tests.Audio
python -m unittest discover -s augly/tests/audio_tests/ -p "*"
Image
Text
python -m unittest discover -s augly/tests/text_tests/ -p "*"
Video
python -m unittest discover -s augly/tests/video_tests/ -p "*"
All
python -m unittest discover -s augly/tests/ -p "*"
Other testing
If applicable, test your changes and paste the output here. For example, if your changes affect the requirements/installation, then test installing augly in a fresh conda env, then make sure you are able to import augly & run the unit test