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] – [Reencode videos with high bitrate] Wulf Rajekhowto:convert-images [2025/01/05 18:28] (current) 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> 
 + 
 +===== lossless changing containers between webm/mov/mp4/mkv =====
  
-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:+webm/mov/mkv/mp4 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 -> mp4 
 +find . -type f \( -iname "*.mkv" -o -iname "*.webm -o -iname "*.mov\) | 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 163: Line 184:
 <code bash processfiles.sh> <code bash processfiles.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 170: Line 190:
 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 186: Line 204:
 </code> </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>
howto/convert-images.1719869010.txt.gz · Last modified: 2024/07/01 22:23 by Wulf Rajek