On Wed, Apr 08, 2020 at 14:38:23 +0300, Alexander Machev wrote: > I want to align the audio stream in the input to has the exact same > duration as the video stream. So, if audio length is lower than video, fill > the gap with silence. If audio stream is over length than video, cut the > audio to fit the video length. > > It seems apad and atrim filters can do the job, but they will force > reencoding of the whole audio stream. > > Is it possible to achieve this without reencoding everything ?
For trimming: There's a muxer flag (fflags) "shortest", which should avoid copying more audio data when using the "copy" codec. A quick test - I created a file with 15s video and 20s audio - shows that the audio is trimmed even when using "-c copy". In tems of adding/padding: That might me possible if you can extract the audio, concat silent audio to the end, and remux it with the video. [*] You can create silent audio with ffmpeg (same channel count, same sample rate), and add it to the extracted audio with the concat demuxer. I can't think of a way how all this can be done in one step though. Cheers, Moritz [*] De- and re-muxing may lose audio sync, if I remember correctly. _______________________________________________ ffmpeg-user mailing list [email protected] https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
