I am attempting to create the appearance of a picture in a picture video using multiple video files.
I've created a .mp4 file using FFMpeg. The video displays correctly in Windows "Movies & TV" app. It does not display correctly in Chrome, Firefox, VLC Media Player or any other app I have. I plan to display the video in a Browser, so cross browser support is important to me.
The video was created by taking two parts of a video call and doing the following with FFMpeg:
- Put remote video (remote.mp4) in background.
- The remote video should show the first image of the video and appear paused until about 2.501 seconds. I've done this using the itoffset.
- The remote audio should also start playing after 2.501 seconds. Setting the itoffset did not seem to accomplish this so I added a "adelay" option to the filter_complex.
- Placed local video (local.mp4) as an overlay in the bottom right corner.
- The local video and audio should start playing at 0 seconds (immediately upon playing the video.)
- Rotated the background picture 90 degrees (it was recorded sideways).
- Add a audio delay to the remote video so it starts playing the audio stream 2.501 seconds after the start.
- Merge the audio inputs.
- Used aac codec (because it seems popular, I'm totally willing to switch if that would be useful.)
- Use h264 video codec, again because it seems popular.
My FFMpeg command is as follows:
ffmpeg -itsoffset 2.501 -i remote.mp4 -i local.mp4 \ -filter_complex \ " [1:v]scale=iw/4:-1:flags=lanczos[loc0]; \ [0:v]transpose=1[rotate1]; \ [rotate1][loc0]overlay=main_w-overlay_w-10:main_h-overlay_h-10:eof_action=pass[rem0]; \ [0:a]adelay=2501|2501[0adelay]; \ [0adelay]apad[0a]; \ [0a][1:a]amerge=inputs=2[a]" \ -map "[rem0]" -map "[a]" \ -ac 2 -vcodec libx264 \ -ar 44100 -acodec aac \ completed.mp4
- completed.mp4 (16 seconds, 480x640)
- local.mp4 (16 seconds, 640x480)
- remote.mp4 (14 seconds, 640x480, turned sideways)
When I look at the completed video in a browser, instead of being 16 seconds it says 18 seconds. When I use ffprobe on the completed video it says: Duration: 00:00:16.68. The local audio and video also waits 2.501 seconds to play in a browser.
Any help would be wonderful. I have no idea why the browser is rendering it differently than I intend. Thanks!