Answers.Body: <p>Ah I found the answer to my question, I ventured into the ffmpeg documentations again and found that all I had to do was add <strong>-map 1:a</strong> in front of output.mp4 and I also added -c:a copy cause I thought that copies the same codec settings from the original videos or something, not really sure but it seemed better then putting all those specifications in like I did which I actually just left in there from the site that I found the main part of this ffmpeg command on.</p>
  
  <p>My code is now working as I want it and I'll share it below:</p>
  
  <pre>ffmpeg.exe -itsoffset 35 -i overlay.mp4 -i underlay.mp4 -filter_complex 
  "[0]scale=700:-1 [overlay]; [1][overlay] 
  overlay=main_w-overlay_w-30:30:enable='between(t,35,552)'" 
  -map 1:a -c:a copy output.mp4</pre>
  
  <p>The itsoffset is the time before the overlay video starts playing, between(t,35,552) means the overlay video is visible between the 35th second and the 552nd second on the timeline of the output video.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-15T10:21:33.667Z
Answers.Text: Hi what if I want to keep sound of the overlay video?
Answers.UserDisplayName: yuan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-01T00:21:37.307Z
Answers.LastActivityDate: 2018-07-01T00:42:24.140Z
Answers.LastEditDate: 2018-07-01T00:42:24.140Z
Answers.UserDisplayName: Kalder
Body: <p>I'm trying to make a video with an overlay video inside (PiP) but I can't get the sound source right, I need the sound from the underlay video but I keep getting the sound from the overlay video.</p>
  
  <p>I don't have very much experience with or knowledge of ffmpeg, but after some searching around on the internet I found some ffmpeg commands and managed to put the following command together:</p>
  
  <pre>ffmpeg.exe -itsoffset 35 -i overlay-race-replay.mp4 -i underlay-race-live.mp4 
  -filter_complex "[0]scale=700:-1 [overlay]; 
  [1][overlay] overlay=main_w-overlay_w-30:30:enable='between(t,35,552)'" 
  -profile:v high -level 4.1 -ar 44100 -ab 128k -s 1920x1080 -vcodec h264 
  -acodec libmp3lame output.mp4
  </pre>
  
  <p>It works great to create a video with an overlay video in it which shows up and starts at 35 seconds and ends and disappears somewhere before the underlay video ends which is just what I want.</p>
  
  <p>Only the problem is the sound! In the output file you only hear the sound from the overlay video, and I want to keep the sound from the underlay video.</p>
  
  <p>Does anyone know how to do this right? 
  What I need is, overlay-race-replay.mp4 resized to a width of 700 with kept ratio, inside underlay-race-live.mp4, showing up after 35 seconds, placed in the top right corner with about 30 pixels margin and only the sound of underlay-race-live.mp4</p>
  
  <p>I would be very grateful for a solution, I think I've injured my brain in the documentations of ffmpeg I really can't make anything of it, it's like algebra to me.</p>
  
Tags: <video><ffmpeg><audio>
Title: Keeping sound from underlay video in creating PIP video with ffmpeg
UserDisplayName: Kalder
ThreadText: # Keeping sound from underlay video in creating PIP video with ffmpeg
  
  (Asked by: username_0 on 2018-06-30)
  
  I'm trying to make a video with an overlay video inside (PiP) but I can't get the sound source right, I need the sound from the underlay video but I keep getting the sound from the overlay video.
  
  I don't have very much experience with or knowledge of ffmpeg, but after some searching around on the internet I found some ffmpeg commands and managed to put the following command together:
  
  ```
  ffmpeg.exe -itsoffset 35 -i overlay-race-replay.mp4 -i underlay-race-live.mp4 
  -filter_complex "[0]scale=700:-1 [overlay]; 
  [1][overlay] overlay=main_w-overlay_w-30:30:enable='between(t,35,552)'" 
  -profile:v high -level 4.1 -ar 44100 -ab 128k -s 1920x1080 -vcodec h264 
  -acodec libmp3lame output.mp4
  
  ```
  
  It works great to create a video with an overlay video in it which shows up and starts at 35 seconds and ends and disappears somewhere before the underlay video ends which is just what I want.
  
  Only the problem is the sound! In the output file you only hear the sound from the overlay video, and I want to keep the sound from the underlay video.
  
  Does anyone know how to do this right?
  What I need is, overlay-race-replay.mp4 resized to a width of 700 with kept ratio, inside underlay-race-live.mp4, showing up after 35 seconds, placed in the top right corner with about 30 pixels margin and only the sound of underlay-race-live.mp4
  
  I would be very grateful for a solution, I think I've injured my brain in the documentations of ffmpeg I really can't make anything of it, it's like algebra to me.
  
  **Tags:** video, ffmpeg, audio
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-07-01. Score: 2
  
  Ah I found the answer to my question, I ventured into the ffmpeg documentations again and found that all I had to do was add **-map 1:a** in front of output.mp4 and I also added -c:a copy cause I thought that copies the same codec settings from the original videos or something, not really sure but it seemed better then putting all those specifications in like I did which I actually just left in there from the site that I found the main part of this ffmpeg command on.
  
  My code is now working as I want it and I'll share it below:
  
  ```
  ffmpeg.exe -itsoffset 35 -i overlay.mp4 -i underlay.mp4 -filter_complex 
  "[0]scale=700:-1 [overlay]; [1][overlay] 
  overlay=main_w-overlay_w-30:30:enable='between(t,35,552)'" 
  -map 1:a -c:a copy output.mp4
  ```
  
  The itsoffset is the time before the overlay video starts playing, between(t,35,552) means the overlay video is visible between the 35th second and the 552nd second on the timeline of the output video.
  
  > **Comments:**
  > **username_1**: Hi what if I want to keep sound of the overlay video?  
  
  ---
  
  