Differences between revisions 1 and 20 (spanning 19 versions)
Revision 1 as of 2012-03-13 22:00:27
Size: 565
Editor: SamatJain
Comment:
Revision 20 as of 2016-12-22 22:14:49
Size: 3487
Editor: SamatJain
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Rotate ==

If the camera was recording in "upside down" mode:

{{{#!highlight sh numbers=off
parallel -u 'echo {}; jpegtran -rotate 180 -perfect -copy all -outfile {}.tran {} && mv {}.tran {}' ::: *.jpg
}}}

== Resize & crop ==
Line 2: Line 12:
parallel -u 'echo {}; jpegtran -rotate 180 -perfect -copy all -outfile {}.tran {} && mv {}.tran {}' ::: *.jpg # Crop top
find . -name '*JPG' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -chop 0x486 -resize 1920x1080
# or Crop bottom
find . -name '*JPG' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -gravity South -chop 0x486 -resize 1920x1080
}}}
Line 4: Line 18:
For the GoPro HD Hero 2:

{{{#!highlight sh
Line 5: Line 22:
find . -name '*JPG' -print0 | xargs -0 -P2 -n8 mogrify -crop 2592x1944+0+486 -resize 1920x1080 find . -name '*JPG' -print0 | xargs -0 -P$(nproc) -n256 mogrify -crop 3840x2880+0+720 -resize 1920x1080
}}}
Line 7: Line 25:
# LDR tonemapping
parallel -u 'echo {}; ~/sys/tonemap/tonemapping ~/sys/tonemap/default.tnp {} {}.tonemapped && mv {}.tonemapped {}' ::: *.JPG
For the Xiaomi Yi:
Line 10: Line 27:
mencoder mf://*.JPG -mf fps=15:type=jpg -ovc lavc -oac lavc -of lavf -lavfopts format=webm -lavcopts threads=4:acodec=vorbis:vcodec=libvpx -ffourcc VP80 -o output15.webm {{{#!highlight sh
# 16 MP
# Crop top
find . -name '*jpg' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -chop 0x864 -resize 1920x1080
# Crop top at 4K
find . -name '*jpg' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -chop 0x864 -resize 3840x2160

# 13 MP
# Crop top
find . -name '*jpg' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -chop 0x774 -resize 1920x1080
# Crop top at 4K
find . -name '*jpg' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -chop 0x774 -resize 3840x2160
Line 12: Line 40:

For A6500:

{{{
# Crop bottom, use high-quality resizing
find . -name '*JPG' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -gravity South -chop 0x625 -resize 3840x2160 -filter Lanczos -unsharp
}}}


== LDR tone mapping ==

{{{#!highlight sh numbers=off
parallel -u 'echo {}; ~/sys/tonemap/tonemapping ~/sys/tonemap/default.tnp {} {}.tonemapped && mv {}.tonemapped {}' ::: *.jpg
}}}

batch:

{{{
for i in $(ls); do (cd $i; parallel -u 'echo {}; ~/sys/tonemap/tonemapping ~/sys/tonemap/default.tnp {} {}.tonemapped && mv {}.tonemapped {}' ::: *.jpg); done;
}}}

== Encode to video (WebM, MP4) ==

{{{#!highlight sh numbers=off
# Old mencoder line
mencoder mf://*.JPG -mf fps=15:type=jpg -ovc lavc -oac lavc -of lavf -lavfopts format=webm -lavcopts threads=4:acodec=vorbis:vcodec=libvpx -ffourcc VP80 -o $(basename $(pwd)).webm

# New MPV line, for VP9
# qmax appears to set video quality… lower number (e.g. qmax=25) is better quality, higher number (default is qmax=63) is less quality
mpv mf://*.jpg -mf-fps=15 -mf-type=jpeg --ovc=libvpx-vp9 -ovcopts qmax=30,threads=$(nproc) -o $(basename $(pwd)).vp9.webm

# MPV for x264
mpv mf://*.jpg -mf-fps=15 -mf-type=jpeg --ovc=libx264 --ovcopts threads=$(nproc) -o $(basename $(pwd)).mp4
# MPV for lossless x264
mpv mf://*.jpg -mf-fps=15 -mf-type=jpeg --ovc=libx264 --ovcopts preset=veryslow,qp=0,threads=$(nproc) -o $(basename $(pwd)).lossless.mp4

}}}

See https://github.com/Argon-/mpv-config/blob/master/encoding-profiles.conf for more mpv encoding profiles.

batch:

{{{
# use one of the commands from above
COMMAND='' # make sure to use single quotes
for i in $(ls); do (echo cd $i; echo $COMMAND; echo cd ../); done
}}}

== Merge files ==

After placing all the WebM files in one directory, merge with:

{{{#!highlight sh numbers=off
f() { args=("$1"); shift; args+=("${@/#/+ }"); echo "${args[@]}"; }; echo mkvmerge $(f $(ls *webm))
}}}

or for MP4:

{{{#!highlight sh numbers=off
echo -n MP4Box ""; for i in $(ls *mp4); do echo -n -cat $i "" ; done; echo -new out.mp4
}}}

== Interesting links ==

Open-source implementation of Microsoft's HyperLapse: [[https://github.com/willcrichton/hyperlapse|willcrichton/hyperlapse: Open-source implementation of MSR Hyperlapse]]

Rotate

If the camera was recording in "upside down" mode:

parallel -u 'echo {}; jpegtran -rotate 180 -perfect -copy all -outfile {}.tran {} && mv {}.tran {}' ::: *.jpg

Resize & crop

   1 # Crop top
   2 find . -name '*JPG' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -chop 0x486 -resize 1920x1080
   3 # or Crop bottom
   4 find . -name '*JPG' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -gravity South -chop 0x486 -resize 1920x1080

For the GoPro HD Hero 2:

   1 # Crop top
   2 find . -name '*JPG' -print0 | xargs -0 -P$(nproc) -n256 mogrify -crop 3840x2880+0+720 -resize 1920x1080

For the Xiaomi Yi:

   1 # 16 MP
   2 # Crop top
   3 find . -name '*jpg' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -chop 0x864 -resize 1920x1080
   4 # Crop top at 4K
   5 find . -name '*jpg' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -chop 0x864 -resize 3840x2160
   6 
   7 # 13 MP
   8 # Crop top
   9 find . -name '*jpg' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -chop 0x774 -resize 1920x1080
  10 # Crop top at 4K
  11 find . -name '*jpg' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -chop 0x774 -resize 3840x2160

For A6500:

# Crop bottom, use high-quality resizing
find . -name '*JPG' -print0 | xargs -0 -P$(nproc) -n256 gm mogrify -gravity South -chop 0x625 -resize 3840x2160 -filter Lanczos -unsharp

LDR tone mapping

parallel -u 'echo {}; ~/sys/tonemap/tonemapping ~/sys/tonemap/default.tnp {} {}.tonemapped && mv {}.tonemapped {}' ::: *.jpg

batch:

for i in $(ls); do (cd $i; parallel -u 'echo {}; ~/sys/tonemap/tonemapping ~/sys/tonemap/default.tnp {} {}.tonemapped && mv {}.tonemapped {}' ::: *.jpg); done;

Encode to video (WebM, MP4)

# Old mencoder line
mencoder mf://*.JPG -mf fps=15:type=jpg -ovc lavc -oac lavc -of lavf -lavfopts format=webm -lavcopts threads=4:acodec=vorbis:vcodec=libvpx -ffourcc VP80 -o $(basename $(pwd)).webm

# New MPV line, for VP9
# qmax appears to set video quality… lower number (e.g. qmax=25) is better quality, higher number (default is qmax=63) is less quality
mpv mf://*.jpg -mf-fps=15 -mf-type=jpeg --ovc=libvpx-vp9 -ovcopts qmax=30,threads=$(nproc) -o $(basename $(pwd)).vp9.webm

# MPV for x264
mpv mf://*.jpg -mf-fps=15 -mf-type=jpeg --ovc=libx264 --ovcopts threads=$(nproc) -o $(basename $(pwd)).mp4
# MPV for lossless x264
mpv mf://*.jpg -mf-fps=15 -mf-type=jpeg --ovc=libx264 --ovcopts preset=veryslow,qp=0,threads=$(nproc) -o $(basename $(pwd)).lossless.mp4

See https://github.com/Argon-/mpv-config/blob/master/encoding-profiles.conf for more mpv encoding profiles.

batch:

# use one of the commands from above
COMMAND='' # make sure to use single quotes
for i in $(ls); do (echo cd $i; echo $COMMAND; echo cd ../); done

Merge files

After placing all the WebM files in one directory, merge with:

f() { args=("$1"); shift; args+=("${@/#/+ }"); echo "${args[@]}"; }; echo mkvmerge $(f $(ls *webm))

or for MP4:

echo -n MP4Box ""; for i in $(ls *mp4); do echo -n -cat $i "" ; done; echo -new out.mp4

Open-source implementation of Microsoft's HyperLapse: willcrichton/hyperlapse: Open-source implementation of MSR Hyperlapse

SamatsWiki: GoPro (last edited 2017-04-14 09:43:49 by SamatJain)