Body: <p>I have a 16 second video that contains an audio stream and a 4:18 audio file (music). I want to fade the audio and trim it to end at 16 seconds. Here's what I'm trying:</p>
  <pre><code>ffmpeg -i test.wav -i test.mp4 -y -filter_complex &quot;[0:a]afade=t=out:st=12:d=4:curve=qua[faded];[faded]atrim=0:16,asetpts=PTS-STARTPTS[aout]&quot; -map 1:v -map &quot;[aout]&quot; -ac 2 test-render.mp4
  </code></pre>
  <p>The video renders with no errors and watching the time I see it end at 15.99</p>
  <pre><code>frame=  480 fps=115 q=-1.0 Lsize=    3992kB time=00:00:15.99 bitrate=2043.9kbits/s speed=3.84x
  </code></pre>
  <p>BUT, the resulting video is the duration of the audio file - 4:18.
  The audio fades and the video stops right where it is supposed to but freezes at 16 seconds. Here's ffprobe for the resulting video:
  <a href="https://i.sstatic.net/tkoH4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tkoH4.png" alt="enter image description here" /></a></p>
  <p>No matter what I've tried I can't seem to figure out how to resolve this.
  I'm using ffmpeg 4.4.1</p>
  <p>Any help would be greatly appreciated. I'm stumped.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-01T04:17:51.583Z
Comments.Text: Add -report and rerun. Share link to report.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-01T14:17:40.047Z
Comments.Text: It looks like there's an issue with the audio file itself. I tried with a different audio file and it rendered a 16 second video as it should have. I rendered an m4a that shows to be 16 seconds in any player, such as the one in Finder. But when I run ffprobe on it I see the duration showing to be 4:18...
  `Duration: 00:04:18.35, start: 0.000000, bitrate: 7 kb/s`
  Also see that Stream #0:1 contains useless metadata.
  `
  `Stream #0:1(eng): Data: bin_data (text / 0x74786574)
      Metadata:
        handler_name    : SubtitleHandler`
Comments.UserDisplayName: Swampthang
Tags: <ffmpeg><audio>
Title: ffmpeg atrim not working with shorter video - results in same duration as wav file
UserDisplayName: Swampthang
ThreadText: # ffmpeg atrim not working with shorter video - results in same duration as wav file
  
  (Asked by: username_0 on 2022-03-01)
  
  I have a 16 second video that contains an audio stream and a 4:18 audio file (music). I want to fade the audio and trim it to end at 16 seconds. Here's what I'm trying:
  
  ```
  ffmpeg -i test.wav -i test.mp4 -y -filter_complex "[0:a]afade=t=out:st=12:d=4:curve=qua[faded];[faded]atrim=0:16,asetpts=PTS-STARTPTS[aout]" -map 1:v -map "[aout]" -ac 2 test-render.mp4
  
  ```
  
  The video renders with no errors and watching the time I see it end at 15.99
  
  ```
  frame=  480 fps=115 q=-1.0 Lsize=    3992kB time=00:00:15.99 bitrate=2043.9kbits/s speed=3.84x
  
  ```
  
  BUT, the resulting video is the duration of the audio file - 4:18.
  The audio fades and the video stops right where it is supposed to but freezes at 16 seconds. Here's ffprobe for the resulting video:
  [![enter image description here](https://i.sstatic.net/tkoH4.png)](https://i.sstatic.net/tkoH4.png)
  
  No matter what I've tried I can't seem to figure out how to resolve this.
  I'm using ffmpeg 4.4.1
  
  Any help would be greatly appreciated. I'm stumped.
  
  **Tags:** ffmpeg, audio
  
  > **Comments:**
  > **username_1**: Add -report and rerun. Share link to report.  
  > **username_0**: It looks like there's an issue with the audio file itself. I tried with a different audio file and it rendered a 16 second video as it should have. I rendered an m4a that shows to be 16 seconds in any player, such as the one in Finder. But when I run ffprobe on it I see the duration showing to be 4:18... `Duration: 00:04:18.35, start: 0.000000, bitrate: 7 kb/s` Also see that Stream #0:1 contains useless metadata. ` `Stream #0:1(eng): Data: bin_data (text / 0x74786574)     Metadata:       handler_name    : SubtitleHandler`  
  
  ---
  
  ## 0 answers
  
  