Main Menu

convert HEIC format

Started by filmfan, May 09, 2022, 12:17:33 PM

Previous topic - Next topic

filmfan

I have checked the FAQ and tried to search the forum though search seems to be disabled.  I'm sure this is covered in the forum and would greatly appreciate being pointed to the discussion.
My goal is to convert photos from an iPhone to .jpg, I also want to rename each photo with standard YYYYmmddhhmmss and preferably subsecond if possible just to avoid conflicts in naming if photos were taken in the same second. Is the original file extension a 'tag'?  If I use an approach like exiftool "-FileName<CreateDate" -d '%Y%m%d_%H%M%S.%%e' DIR  can  I just force the new name to end in .jpg, or is an actual conversion required?  Also is there a discussion of issues created by the iphone photo format with the accompanying short video?
Thank you for considering

StarGeek

#1
Exiftool cannot edit or convert image data.  You can stick a .jpg extension on a file but that doesn't change what the file actually is.  It will still be a HEIC file.  What you need to do is find an actual conversion program.  If you're on Windows, then Irfanview is a free program which can do the conversions in batch for you.  If you need a command line program then you could use ImageMagick, which is free and cross platform.  I can't recommend anything for other platforms but there are plenty of options out there.

The search feature is unfortunately disabled because the hosting company has disabled this website on high loads (see this post).  You can search these forums through other search engines by adding Site:Exiftool.org to any search terms.  For some reason, both Bing and Google do a poor job of indexing these forums (see this post by me).  Yandex seems to do a much better job, but it is a Russian company, which is a problem in the current situation.
Example links
Google link
Bing link
Yandex link
DuckDuckGo link
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

chuck lee

If you are under linux, you can try heif-convert in command line converting heic/heif to jpg.  See https://github.com/strukturag/libheif  for details.  :) 

filmfan

Thank you for the information. Sorry for my confusion. Yes I am using Linux.  Thanks to libimobile device and ifuse, I am now able to get everything from the DCIM directory in the iPhone onto this computer.  I would appreciate any thoughts on this plan: copy the files, rename according to create/date time with exiftool (exiftool "-FileName<CreateDate" -d "%Y%m%d_%H%M%S.%%e" DIR), then convert heic to jpg and mov to mp4 using potentially magemagick or the other command line utility mentioned. 

Also, though initially all the files in the directory have names like 'IMG_0655.MOV', renaming the files by date/time with exiftool as above is frequently running into a problem where that file already exists.  Does this suggest multiple files with the same date/timestamp down to the second?  Is there a way exiftool can be instructed to include subsecond time information in the new filehame, or to automatically apend 'b', 'c', etc. if a filename already exists?

Thanks again

StarGeek

Quote from: filmfan on May 11, 2022, 05:26:05 AM
Is there a way exiftool can be instructed to include subsecond time information in the new filehame, or to automatically apend 'b', 'c', etc. if a filename already exists?

Use the %c variable to add a copy number.  See the -w (-TextOut) option for details.  If you include it in the -d (-dateFormat) option format string, you need to double the percent signs %%c the same as they are doubled in the %e extension variable.  Also see Renaming Examples.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

chuck lee

Convert mov to mp4, check this site: https://askubuntu.com/questions/1340939/what-is-the-easiest-way-to-convert-files-to-an-mp4   
You can use ffmpeg or handbrake(GUI). 

StarGeek

That would be a destructive recompress.  Handbrake should only be used if it is necessary to re-encode the video with a different codec or change the size.

It would be better to remux the video from Mov to MP4.  That has the advantage of being very quick and lossless.  The second command in this StackOverflow answer would be the one to use, as it will copy all streams into the new container.
ffmpeg -i input.mov -c copy -map 0 output.mp4

Another alternative that has a GUI would be to use a program like AVIDemux with codec set to copy.  Despite it's name, it will work with MKV, Mov, MP4, and other video types


One important thing to remember is that any non-standard data will be lost in any operation.  This would include EXIF data and GPS tracks.  There is no standard for inserting this data into a video file and every camera manufacturer includes this data in different ways.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

filmfan

Thanks again for the suggestions.  The copy flag works perfectly.  After renaming, based on your suggestion I plan to use ffmpeg to batch convert the .mov files and to batch convert the .heic files to .jpg using imagemagick mogrify. Any thoughts on the quality parameter?. 
Thanks also for the reminders about loss of metadata in some of these conversions.  The only metadata I think I'll care about is the creation date/time, and that will become the file name.  But I need to keep the original files as copied from the iPhone so that each time I download off the phone I have will only get new photos/videos. So I should be able to get any other metadata from the original files.

StarGeek

Quote from: filmfan on May 12, 2022, 03:08:04 AM
batch convert the .heic files to .jpg using imagemagick mogrify. Any thoughts on the quality parameter?

Not really.  Even though I often recommend ImageMagick, I don't actually use it that often.  But I tend to use very high quality settings when I convert files to jpg.

Looking it up, ImageMagick defaults to -quality 85.  It would depend upon your use case but I probably would use -quality 95 in most cases, unless this was for something like putting on a web page, where smaller size would be a bit more important.  Higher than 95 will increase the file size without much increase in quality.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

filmfan