User Tools

Site Tools


howto:convert-images

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howto:convert-images [2024/07/01 22:23] – [downscale video to 720p mkv] Wulf Rajekhowto:convert-images [2025/05/20 11:23] (current) – [lossy conversion of png to jpg] Wulf Rajek
Line 28: Line 28:
 </code> </code>
  
-===== lossless changing container from webm to mkv =====+===== lossy conversion of png to jpg ===== 
 +Converts all png files in the directory recursively to jpg 
 +<code> 
 +find . -iname '*.png' | while read i; do mogrify -format jpg "$i" && rm "$i"; echo "Converted $i to ${i%.*}.jpg"; done 
 +</code>
  
-Webm is a container similar to mkv and can contain various encoded video or audio streams. To change the container from webm to mkv, the following command can be used:+===== 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.: 
 +<code> 
 +convert logo.png -define icon:auto-resize=256,64,48,32,16 favicon.ico 
 +</code> 
 + 
 +===== lossless changing containers between webm/mov/mp4/mkv/m4v ===== 
 + 
 +webm/mov/mkv/mp4/m4v are container formats and can contain various encoded video or audio streams. To change the container between each other, the following command can be used, provided the used codecs inside the containers are compatible:
 <code> <code>
 ffmpeg -i file.webm -c:a copy -c:v copy file.mkv ffmpeg -i file.webm -c:a copy -c:v copy file.mkv
  
 #recursively changing containers: #recursively changing containers:
-find . -name '*.webm' -type f -exec bash -c 'ffmpeg -i "$0" -c:a copy -c:v copy "${0%.webm}.mkv"' {} \; +find . -iname '*.webm' -type f -exec bash -c 'ffmpeg -i "$0" -c:a copy -c:v copy "${0%.*}.mkv"' {} \; 
-#find . -type f -name '*.webm' -delete+#find . -type f -iname '*.webm' -delete 
 + 
 +#lossless change container mkv, webm, mov, m4v -> mp4 
 +find . -type f \( -iname "*.mkv" -o -iname "*.webm" -o -iname "*.mov" -o -iname "*.m4v" \) | while read f; do 
 +    ffmpeg -i "$f" -codec copy "${f%.*}.mp4" 
 +done
 </code> </code>
  
-===== change container mkv <-> mp4 ===== +===== 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:+
 <code> <code>
-ffmpeg -i input.mkv -codec copy output.mp4+#High quality non-mp4 to mp4 conversion 
 +find . -type f \( -iname "*.mpg" -o -iname "*.asf" -o -iname "*.wmv" -o -iname "*.mpg" -o -iname "*.mpeg" -o -iname "*.avi" -o -iname "*.divx" -o -iname "*.rmvb" -o -iname "*.rm" -o -iname "*.m4v" -o -iname "*.flv" \) | while read f; do 
 +    ffmpeg -nostdin -i "$f" -vcodec libx264 -acodec aac "${f%.*}.mp4
 +done
 </code> </code>
 +===== find all non-mp4 files =====
 +<code>
 +#Find non-mp4 files
 +find . -type f -not \( -iname "*.mp4" \)
 +</code>
 +
 +
 +
 +
  
 ===== downscale video to 720p mkv ===== ===== downscale video to 720p mkv =====
Line 162: Line 189:
  
 <code bash processfiles.sh> <code bash processfiles.sh>
-bitrateprocess.sh 
 #!/bin/bash #!/bin/bash
-MYFILES=$(find /media/videofiles -type f -iname "*.+MYFILES=$(find /media/videofiles -type f -iname "*.mp4")
-p4")+
 SAVEIFS=$IFS SAVEIFS=$IFS
  
Line 171: Line 196:
 for FILE in ${MYFILES} for FILE in ${MYFILES}
 do do
-  bitrate=$(ffprobe -v quiet -select_streams v:0 -show_entri +  bitrate=$(ffprobe -v quiet - select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 $FILE)
-es stream=bit_rate -of default=noprint_wrappers=1:nokey=1 $+
-ILE)+
   if ! [[ $bitrate =~ ^[0-9]+$ ]];   if ! [[ $bitrate =~ ^[0-9]+$ ]];
   then   then
Line 185: Line 208:
 done done
 IFS=$SAVEIFS IFS=$SAVEIFS
 +</code>
 +
 +
 +===== 3D VR SBS to 2D =====
 +
 +https://blog.interstellar.co.jp/en/2022/06/21/converting-vr180-videos-to-2d-videos-with-ffmpeg/
 +
 +<code>
 +ffmpeg -i input.mp4 -vf v360=input=equirect:output=flat:ih_fov=180:iv_fov=180:h_fov=93:v_fov=121:in_stereo=sbs:w=960:h=640 -codec:v h264 output.mp4
 +</code>
 +
 +https://video.stackexchange.com/questions/21084/how-to-convert-a-3d-movie-to-2d-using-ffmpeg
 +
 +<code>
 +ffmpeg -i input.mkv -vf stereo3d=sbsl:ml -metadata:s:v:0 stereo_mode="mono" output.mkv
 +</code>
 +Use sbsl2:ml or  -aspect 16:9 if the aspect ratio is wrong
 +
 +
 +https://stackoverflow.com/questions/66960003/unwarping-180-vr-footage-with-ffmpeg-v360-filter
 +
 +
 +https://github.com/paulpaul999/vr-video-notes/blob/main/vr-to-flat/README.md
 +<code>
 +ffmpeg -i equirectangular.mp4 -filter:v "v360=input=hequirect:output=flat:in_stereo=sbs:out_stereo=2d:d_fov=125:w=1920:h=1080:pitch=+5" -map 0 -c copy -c:v h264 -pix_fmt yuv420p flat.mp4
 +</code>
 +
 +===== 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. 
 +
 +<code>
 +for i in {01..33}; do 
 +  ffmpeg -i "Chapter "$i".mp3" -af "pan=stereo|c0=c0|c1=c0" "Chapter "$i"s.mp3"; 
 +done
 </code> </code>
  
howto/convert-images.1719868986.txt.gz · Last modified: by Wulf Rajek