Last active
January 5, 2024 03:40
-
-
Save ajmas/63b40dee8e52958ef2b9d1f6839193c2 to your computer and use it in GitHub Desktop.
Revisions
-
ajmas revised this gist
Jan 5, 2024 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,10 @@ #!/bin/sh ## Quick script to convert webp files to mp4. Makes use of webpmux, ImageMagick and ffmpeg input=$1 output_base=/tmp output_file=output.mp4 regex="Number of frames: ([0-9]+)" info=`webpmux -info "$1"` @@ -19,6 +22,6 @@ then done # Take the frames and assemble the MP4. We need to tune the FPS, since right now it is hardcoded ffmpeg -framerate 5 -pattern_type glob -i "$output_base/"'frame_*.png' -c:v libx264 -pix_fmt yuv420p "$output_file" fi -
ajmas revised this gist
Jan 5, 2024 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,11 +12,13 @@ then frame_count=$(($frame_count)) for idx in $(seq -f '%02g' 01 $frame_count); do # Extract the frames from the webp webpmux -get frame $idx "$1" -o "$output_base/frame_$idx.png" # Use ImageMagick to convert the PNG to PNG, since the one outputted by webpmux seems unsupported by ffmpeg convert "$output_base/frame_$idx.png" "$output_base/frame_$idx.png" done # Take the frames and assemble the MP4. We need to tune the FPS, since right now it is hardcoded ffmpeg -framerate 5 -pattern_type glob -i "$output_base/"'frame_*.png' -c:v libx264 -pix_fmt yuv420p output.mp4 fi -
ajmas revised this gist
Jan 5, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,7 @@ then for idx in $(seq -f '%02g' 01 $frame_count); do webpmux -get frame $idx "$1" -o "$output_base/frame_$idx.png" # Use ImageMagick to convert the PNG to PNG, since the one outputted by webpmux seems unsupported by ffmpeg convert "$output_base/frame_$idx.png" "$output_base/frame_$idx.png" done -
ajmas created this gist
Jan 5, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #!/bin/sh input=$1 output_base=/tmp regex="Number of frames: ([0-9]+)" info=`webpmux -info "$1"` if [[ $info =~ $regex ]] then rm "$output_base/frame_*.png" frame_count="${BASH_REMATCH[1]}" frame_count=$(($frame_count)) for idx in $(seq -f '%02g' 01 $frame_count); do webpmux -get frame $idx "$1" -o "$output_base/frame_$idx.png" convert "$output_base/frame_$idx.png" "$output_base/frame_$idx.png" done ffmpeg -framerate 5 -pattern_type glob -i "$output_base/"'frame_*.png' -c:v libx264 -pix_fmt yuv420p output.mp4 fi