howto:convert-images
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| howto:convert-images [2024/02/26 17:44] – [downscale video to 720p mkv] Wuff | howto:convert-images [2025/05/20 11:23] (current) – [lossy conversion of png to jpg] Wuff | ||
|---|---|---|---|
| Line 28: | Line 28: | ||
| </ | </ | ||
| - | ===== lossless changing container from webm to mkv ===== | + | ===== lossy conversion of png to jpg ===== |
| + | Converts all png files in the directory recursively to jpg | ||
| + | < | ||
| + | find . -iname ' | ||
| + | </ | ||
| - | Webm is a container similar | + | ===== png to ico ===== |
| + | To create favicon ico files, the following command creates multiple sizes and stores them in the ico file and keeps transparency. Adjust as required.: | ||
| + | < | ||
| + | convert logo.png -define icon: | ||
| + | </ | ||
| + | |||
| + | ===== lossless changing containers between webm/ | ||
| + | |||
| + | webm/ | ||
| < | < | ||
| ffmpeg -i file.webm -c:a copy -c:v copy file.mkv | ffmpeg -i file.webm -c:a copy -c:v copy file.mkv | ||
| # | # | ||
| - | find . -name ' | + | find . -iname ' |
| - | #find . -type f -name ' | + | #find . -type f -iname ' |
| + | |||
| + | #lossless change container mkv, webm, mov, m4v -> mp4 | ||
| + | find . -type f \( -iname " | ||
| + | ffmpeg -i " | ||
| + | done | ||
| </ | </ | ||
| - | ===== change container mkv < | + | ===== high quality conversion to mp4 ===== |
| - | + | ||
| - | To only change the container use the following example command - provided the codecs are compatible with mp4. The quality and size stays the same: | + | |
| < | < | ||
| - | ffmpeg -i input.mkv | + | #High quality non-mp4 to mp4 conversion |
| + | find . -type f \( -iname " | ||
| + | | ||
| + | done | ||
| </ | </ | ||
| + | ===== find all non-mp4 files ===== | ||
| + | < | ||
| + | #Find non-mp4 files | ||
| + | find . -type f -not \( -iname " | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| ===== downscale video to 720p mkv ===== | ===== downscale video to 720p mkv ===== | ||
| Line 93: | Line 120: | ||
| if [ -f " | if [ -f " | ||
| echo " | echo " | ||
| - | output=" | + | output=" |
| # Check if mp4 container is desired and if subtitle is ASS format, then convert to srt, otherwise just copy subs | # Check if mp4 container is desired and if subtitle is ASS format, then convert to srt, otherwise just copy subs | ||
| subtitles_present=$(ffprobe -v error -select_streams s -show_entries stream=codec_name -of csv=p=0:s=x " | subtitles_present=$(ffprobe -v error -select_streams s -show_entries stream=codec_name -of csv=p=0:s=x " | ||
| Line 101: | Line 128: | ||
| else | else | ||
| subtitle_option=" | subtitle_option=" | ||
| + | fi | ||
| + | #check framerate to only ever reduce it and not increase it | ||
| + | # ffprobe returns 25/1 or 24000/1001. result needs to be calculated and needs to be an integer, thus the bash $(( )). | ||
| + | fps=$(ffprobe -v 0 -of csv=p=0 -select_streams v -show_entries stream=avg_frame_rate " | ||
| + | if [ " | ||
| + | # some video files return 0 / 0 for avg_frame_rate, | ||
| + | fps=$(ffprobe -v 0 -of csv=p=0 -select_streams v -show_entries stream=r_frame_rate " | ||
| + | fi | ||
| + | fps=$(( $fps )) | ||
| + | if [ $fps -gt 30 ]; then | ||
| + | fps_option=" | ||
| + | else | ||
| + | fps_option="" | ||
| fi | fi | ||
| #-c:a copy # | #-c:a copy # | ||
| #$binary -i " | #$binary -i " | ||
| # using complex filter to prevent upscaling and only ever downscale | # using complex filter to prevent upscaling and only ever downscale | ||
| - | cmd=$binary' | + | cmd=$binary' |
| - | | + | $binary -i " |
| if [ $? -eq 0 ]; | if [ $? -eq 0 ]; | ||
| then | then | ||
| actualheight=$(ffprobe -v error -select_streams v -show_entries stream=height -of csv=p=0:s=x " | actualheight=$(ffprobe -v error -select_streams v -show_entries stream=height -of csv=p=0:s=x " | ||
| # | # | ||
| - | output2=" | + | output2=" |
| mv " | mv " | ||
| echo " | echo " | ||
| Line 121: | Line 161: | ||
| fi | fi | ||
| done | done | ||
| + | |||
| + | # When using in Nemo, it's helpful to force a key to be pressed before closing the terminal to see the status or any errors. Uncomment the following line: | ||
| + | |||
| + | #echo;read -rsn1 -p "Press any key to continue . . ."; | ||
| </ | </ | ||
| Line 128: | Line 172: | ||
| Name=Video Downscale to max 720p | Name=Video Downscale to max 720p | ||
| Comment=Video Downscale to max 720p | Comment=Video Downscale to max 720p | ||
| - | Exec=<video_downscale.sh %F;echo;read -rsn1 -p "Press any key to continue . . ."; | + | Exec=video_downscale.sh %F |
| Icon-Name=stock_down | Icon-Name=stock_down | ||
| Selection=notnone | Selection=notnone | ||
| - | Extensions=mp4; | + | Extensions=mp4; |
| - | #Quote=double | + | Quote=double |
| EscapeSpaces=true | EscapeSpaces=true | ||
| Terminal=true | Terminal=true | ||
| + | </ | ||
| + | |||
| + | When using in Nemo, it's helpful to add the following to the very end of the video_downscale.sh script to force a key to be pressed before closing the terminal to see the status or any errors: | ||
| + | < | ||
| + | echo;read -rsn1 -p "Press any key to continue . . ."; | ||
| + | </ | ||
| + | |||
| + | ===== Reencode videos with high bitrate ===== | ||
| + | |||
| + | <code bash processfiles.sh> | ||
| + | #!/bin/bash | ||
| + | MYFILES=$(find / | ||
| + | SAVEIFS=$IFS | ||
| + | |||
| + | IFS=$(echo -en " | ||
| + | for FILE in ${MYFILES} | ||
| + | do | ||
| + | bitrate=$(ffprobe -v quiet - select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1: | ||
| + | if ! [[ $bitrate =~ ^[0-9]+$ ]]; | ||
| + | then | ||
| + | continue | ||
| + | fi | ||
| + | if [ $bitrate -gt 8000000 ] | ||
| + | then | ||
| + | echo $bitrate" | ||
| + | video_downscale.sh " | ||
| + | fi | ||
| + | done | ||
| + | IFS=$SAVEIFS | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== 3D VR SBS to 2D ===== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | < | ||
| + | ffmpeg -i input.mp4 -vf v360=input=equirect: | ||
| + | </ | ||
| + | |||
| + | https:// | ||
| + | |||
| + | < | ||
| + | ffmpeg -i input.mkv -vf stereo3d=sbsl: | ||
| + | </ | ||
| + | Use sbsl2:ml or -aspect 16:9 if the aspect ratio is wrong | ||
| + | |||
| + | |||
| + | https:// | ||
| + | |||
| + | |||
| + | https:// | ||
| + | < | ||
| + | ffmpeg -i equirectangular.mp4 -filter:v " | ||
| + | </ | ||
| + | |||
| + | ===== Mono to Stereo MP3 ===== | ||
| + | |||
| + | Conversion using ffmpeg -ac 2 reduces volume by 3db, apparently to keep perceived loudness the same. To maintain the same volume use pan as below. | ||
| + | |||
| + | < | ||
| + | for i in {01..33}; do | ||
| + | ffmpeg -i " | ||
| + | done | ||
| </ | </ | ||
howto/convert-images.1708969482.txt.gz · Last modified: by Wuff