Experiment: Melting a dyed ice cube in salt water and fresh water – which one melts first?

In a podcast I listened to yesterday the experiment was discussed, using normal ice cubes. And they suggested to repeat the experiment with dyed ice cubes or dyed water. Yesterday I prepared the ice cubes and today did the experiment.

Some words about the preparation: Dissolving salt creates heat, hence I allowed for time so that the water could reach room temperature again. Therefore, the interesting bit only starts after a minute into the time lapse, or 20 minutes in real time.

The ice cubes start melting immediately, both distribute a bit of blue water to their glasses. However, the difference becomes visible very quickly: In the fresh water a constant stream of blue water flows to the bottom of the glass. In the salt water glass the blue melt water from the ice cube creates a layer on the top of the glass. The ice cube swims in this cold water, is isolated from the warm water, and hence survives about twice as long.

The reason of the different behaviour is related to density. A cold liquid has a higher density than a warm liquid, and hence sinks to the bottom (in the same way that a piece of metal has a higher density than water, or humans have a higher density than air). However, dissolving salt in water increases the density of that water, and the saltwater has a higher density than the cold water from the ice cube.

When the experiment was described, I guessed wrong. Using salt to melt ice on streets, I thought the ice cube in the salt water will melt quicker, due to a chemical reactions. However, as the salt is already dissolved, no heat can come from destroying the crystal structure (and that would be a physical reaction and not a chemical reaction anyway).

I didn’t want to show an hour long video on youtube, hence speed up certain parts of the video. For this I used the free ffmpeg tool on a Ubuntu 20 laptop. Running the code below took about 10 Minutes on my Laptop:

ffmpeg -i ../orig.mp4 -ss 00:00:00 -to 00:00:05 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.10*PTS" output_01.mp4 && rm temp.mp4
ffmpeg -i ../orig.mp4 -ss 00:00:05 -to 00:00:27 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.50*PTS" output_02.mp4 && rm temp.mp4
ffmpeg -i ../orig.mp4 -ss 00:00:27 -to 00:00:54 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.10*PTS" output_03.mp4 && rm temp.mp4
ffmpeg -i ../orig.mp4 -ss 00:00:54 -to 00:01:12 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.50*PTS" output_04.mp4 && rm temp.mp4
ffmpeg -i ../orig.mp4 -ss 00:01:12 -to 00:03:05 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.10*PTS" output_05.mp4 && rm temp.mp4
ffmpeg -i ../orig.mp4 -ss 00:03:05 -to 00:03:12 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.33*PTS" output_06.mp4 && rm temp.mp4
ffmpeg -i ../orig.mp4 -ss 00:03:12 -to 00:03:20 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.10*PTS" output_07.mp4 && rm temp.mp4
ffmpeg -i ../orig.mp4 -ss 00:03:20 -to 00:19:50 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.01*PTS" output_08.mp4 && rm temp.mp4
ffmpeg -i ../orig.mp4 -ss 00:19:50 -to 00:20:10 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.10*PTS" output_09.mp4 && rm temp.mp4
ffmpeg -i ../orig.mp4 -ss 00:20:10 -to 00:20:40 -c copy output_80.mp4
ffmpeg -i ../orig.mp4 -ss 00:20:40 -to 00:21:00 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.15*PTS" output_81.mp4 && rm temp.mp4
ffmpeg -i ../orig.mp4 -ss 00:21:00 -to 00:27:11 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.05*PTS" output_82.mp4 && rm temp.mp4
ffmpeg -i ../orig_02.mp4 -ss 00:00:00 -to 00:07:20 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.05*PTS" output_83.mp4 && rm temp.mp4
ffmpeg -i ../orig_02.mp4 -ss 00:07:20 -to 00:07:27 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.15*PTS" output_84.mp4 && rm temp.mp4
ffmpeg -i ../orig_02.mp4 -ss 00:07:27 -to 00:07:42 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.50*PTS" output_85.mp4 && rm temp.mp4
ffmpeg -i ../orig_02.mp4 -ss 00:07:42 -to 00:07:50 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.15*PTS" output_86.mp4 && rm temp.mp4
ffmpeg -i ../orig_02.mp4 -ss 00:07:50 -to 00:27:11 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.05*PTS" output_87.mp4 && rm temp.mp4
ffmpeg -i ../orig_03.mp4 -ss 00:00:00 -to 00:05:11 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.05*PTS" output_88.mp4 && rm temp.mp4
ffmpeg -i ../orig_03.mp4 -ss 00:05:11 -to 00:05:33 -c copy temp.mp4 && ffmpeg -i temp.mp4 -r 16 -filter:v "setpts=0.20*PTS" output_89.mp4 && rm temp.mp4

for f in $(ls output*.mp4); do
ffmpeg -i $f -c copy -bsf:v h264_mp4toannexb -f mpegts $f.ts
done
CONCAT=$(echo $(ls *.ts) | sed -e "s/ /|/g")
ffmpeg -i "concat:$CONCAT" -c copy -bsf:a aac_adtstoasc VID_20220224_094623206.mp4
rm *.ts

Video modification for time lapse videos

6 Feb 2022 – Ronny Errmann – last modified on 31 March 2022

Some useful bits which helped me to make the time lapse videos I recorded ready to be published on youtube: Youtube Channel Ronny Errmann

Rotate an mp4 video:

For when the phone was upside down during the recording.

ffmpeg -i input.mp4 -c copy -metadata:s:v rotate="180" output.mp4

Crop an mp4 video:

When personal information is in an area of the video.

1. Get the video resolution:

ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input.mp4

2. Modify the video:

ffmpeg -i input.mp4 -filter:v "crop=1280:600:0:120" output.mp4

Cut an mp4 video:

To keep 00:00:00 to 00:01:22, because afterwards only night was recorded as work had to be finished first.

ffmpeg -i input.mp4 -ss 00:00:00 -to 00:01:22 -c copy output.mp4

Merge/concatenate mp4 videos:

When you notice at the end of a time lapse that the sky is still amazing and you recorded a second one.

Version 1 with the concat protocoll (https://trac.ffmpeg.org/wiki/Concatenate)

Several lines of shell script, run with sh:

for f in $(ls input*.mp4); do
ffmpeg -i $f -c copy -bsf:v h264_mp4toannexb -f mpegts $f.ts
done
CONCAT=$(echo $(ls *.ts) | sed -e "s/ /|/g")
ffmpeg -i "concat:$CONCAT" -c copy -bsf:a aac_adtstoasc output.mp4
rm *.ts

Use Version 2 if this fails with:

Codec 'mpeg4' (12) is not supported by the bitstream filter 'h264_mp4toannexb'

Version 2 with the concat demuxer (https://trac.ffmpeg.org/wiki/Concatenate)

rm -f mylist.txt; for f in input*.mp4; do echo "file '$f'" >> mylist.txt; done
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
rm mylist.txt

Change the speed of mp4 videos:

You took a time lapse, but the viewers are bored, because changes are too small. Time to speed the video up.

ffmpeg -i input.mp4 -r 16 -filter:v "setpts=0.50*PTS" output.mp4

0.5*PTS mean twice the speed, 0.1*PTS would mean ten times the speed, and 2*PTS would mean half the speed.

Change of resolution of mp4 videos:

ffmpeg -y -i input.mp4 -vf scale=480:-2,setsar=1:1 -c:v libx264 -c:a copy output.mp4

The 480 gives the horizontal resultion and the heigh is calculated by keeping the same aspect ratio.