Add audio rendering support - #59
danielweinmann wants to merge 1 commit into
Conversation
|
|
Add a complete audio pipeline parallel to the existing video pipeline: - Decode audio from source media files using FFmpeg (libavcodec + libswresample) - Walk OTIO timeline audio tracks: clips, gaps, transitions (crossfade), time warps, track mixing - Extract audio from video clips that contain audio streams - Mux audio alongside video in output containers (MP4, MOV) - Write audio to separate files via -afile option New CLI options: -acodec, -arate, -achannels, -afile, -no_audio New files: - AudioBuffer.h: interleaved float32 audio buffer type - FFmpegAudioRead.h/cpp: audio decoder using FFmpeg + swresample - AudioGraph.h/cpp: OTIO timeline walker for audio (mirrors ImageGraph) - FFmpegAudioWrite.h/cpp: standalone audio file writer Modified files: - FFmpeg.h/cpp: AudioCodec enum (pcm_s16le, pcm_s24le, pcm_f32le, flac, aac) - FFmpegWrite.h/cpp: audio+video muxing in combined writer - App.h/cpp: CLI options and audio render loop integration - TimelineAlgo.h/cpp: getAudioClips() helper - CMakeLists.txt: new sources + libswresample linking - BuildFFmpeg.cmake: AAC codec in minimal build Signed-off-by: Daniel Weinmann <daniel@seasoned.cc>
d44e134 to
3b9bf3c
Compare
|
Hi and thanks for the contribution! You mentioned you are relatively new to C++ but this looks like a fairly substantial change. I took a quick look and overall it looks good, I should have more time to review it next week. I can also try testing it out on Windows. I was curious about this line in App.cpp: What happens when the frame rate is not a multiple of the sample rate (like 29.97)? |
|
Hi, and sorry for the long delay! I think this PR still needs some work for the frame rate issue I mentioned, are you still interested in working on it? |
Hey, @darbyjohnston! Sorry, I had to move on to other projects and won't have time to work on this in the near future. Feel free to take it over or close it. Thank you for your time, and sorry for not being able to take this one across the finish line. |
|
No problem, I will add a couple of fixes and merge the work keeping your attribution intact. Thanks for creating the PR. |
|
Replaced with: #65 |
Summary
This PR adds audio rendering support to toucan. Audio tracks in OTIO timelines are currently ignored — this adds a complete audio pipeline that runs parallel to the existing video pipeline.
I'm new to the project and to C++ in general, so I'd really appreciate any guidance on how to better follow the existing patterns, naming conventions, or architectural decisions. Happy to rework anything that doesn't fit the project's direction.
What it does
-afileoption (useful when piping video to stdout)New CLI options
-acodec <CODEC>-arate <RATE>-achannels <N>-afile <PATH>-no_audioArchitecture
The audio pipeline mirrors the video pipeline:
ImageGraphAudioGraphffmpeg::Readffmpeg::AudioReadffmpeg::Write(video only)ffmpeg::Write(video+audio) +ffmpeg::AudioWriteIImageNode/ImageBufAudioBuffer(interleaved float32)AudioGraphfollows the same OTIO timeline walking pattern asImageGraph— same_track(),_item(),_timeWarps()structure. Audio is processed in frame-aligned chunks (one video frame's worth of samples per call).Known limitations
Files changed
New files (7):
lib/toucanRender/AudioBuffer.h— simple audio buffer structlib/toucanRender/FFmpegAudioRead.h/cpp— FFmpeg audio decoder + libswresamplelib/toucanRender/AudioGraph.h/cpp— OTIO timeline walker for audiolib/toucanRender/FFmpegAudioWrite.h/cpp— standalone audio file writerModified files (10):
lib/toucanRender/FFmpeg.h/cpp— AudioCodec enumlib/toucanRender/FFmpegWrite.h/cpp— audio stream in combined muxerbin/toucan-render/App.h/cpp— CLI options + render looplib/toucanRender/TimelineAlgo.h/cpp—getAudioClips()helperlib/toucanRender/CMakeLists.txt— new sources + libswresamplecmake/SuperBuild/BuildFFmpeg.cmake— AAC in minimal buildTest plan
-no_audioflag correctly suppresses audio-afilewrites separate audio file alongside muxed output