-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3e3e92
commit a004c45
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Max Schnur, Wistia, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
Attribution: | ||
This technology was developed by Max Schnur at Wistia, Inc. Wistia | ||
Max Schnur on GitHub: https://github.com/MaxPower15 | ||
Wistia Website: https://www.wistia.com | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Seamless AAC Split and Stitch Demo | ||
|
||
This repo demonstrates calculations and ffmpeg commands to encode portions of an audio file with the AAC codec and to recombine them without transcoding. | ||
|
||
The general rule is that, when choosing your audio segment sizes, they _need_ to be aligned with AAC frame boundaries. With aligned frame boundaries, we can use the concat demuxer to cut out the silence ffmpeg adds, as well as some extra padding we add to account for AAC's dependency on previous frames. | ||
|
||
This tech is important because it allows faster and more efficient cloud rendering. It may also be used, for example, to render and mux individual HLS segments (TS files) independently of the full file. | ||
|
||
I've add more comments and explanations in the code itself. | ||
|
||
## Requirements | ||
|
||
This demo assumes ffmpeg is installed and compiled with support for the libfdk_aac codec. It also assumes you have a modern version of ruby installed. | ||
|
||
Some versions of ffmpeg (around 5) may not work properly as there was a temporary regression with aac concatenation. ffmpeg 6 seems to work well. The author's build config looks like this: | ||
|
||
``` | ||
ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers | ||
built with Apple clang version 15.0.0 (clang-1500.0.40.1) | ||
configuration: --prefix=/Users/maxschnur/.asdf/installs/ffmpeg/6.0 --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-nonfree --enable-openssl --enable-shared | ||
``` | ||
|
||
## Usage | ||
|
||
Split and stitch: | ||
|
||
ruby run.rb | ||
|
||
You can find all artifacts in the "out" directory: | ||
|
||
ls out | ||
|
||
On a Mac, you may want to examine out/stitched.mp4 with a visualization program. The author uses [Audacity](https://www.audacityteam.org/) for that. | ||
|
||
open -a Audacity out/stitched.mp4 |