Since videos are shot in 16:9 mode, both phones have virtually the same field of view. The Xperia Z2 frame gets a little narrower when you go from 2160p to 1080p but it's nothing major.
Keep in mind that both phones are limited to just 5 minutes of 2160p videos, if you need longer you'll have to settle for good old 1080p.
MP4 containers with the AVC codec are the choice, but the Sony Xperia Z2 uses a higher framerate, 55Mbps, than the Samsung Galaxy S5, 48Mbps. It also has a higher audio bitrate, 156Kbps over 128Kbps, but we actually prefer the sound of the Samsung.
In theory, the higher bitrate should give the Xperia Z2 an advantage in terms of fine detail, but the Galaxy S5 videos actually look sharper. The contrast isn't as good (the shadows are too bright), but the Samsung did get the colors closer to reality.
At 1080p resolution, the bitrates even out at about 17Mbps, but the Xperia Z2 keeps the higher audio bitrate. Here the Galaxy S5 image looks better, though the margin is noticeably slimmer. By the looks of it, Sony's downsampling isn't as smooth as there are some visible jaggies in diagonal lines. Fine detail like text doesn't looks as good as in the Samsung video either.
The two flagships have some extra shooting modes - 1080p @ 60fps and 720p @ 120fps. The 120fps mode on the Xperia Z2 is called Time shift since it plays back at normal speed and transitions to slo-mo at a user selected point in the video.
The Galaxy S5 and Xperia Z2 also have video HDR modes too, but neither works at the highest available 2160p resolution.
Winner: Samsung Galaxy S5. It offered a sharper image in both 2160p and 1080p modes, plus the audio sounded better, even if the contrast wasn't quite what we would have liked.
The Sony Xperia Z2 videos are pretty good in general but loses the head to head combat at both resolutions.