Convert cover art to Ogg audio files

Started by Clamarc, March 11, 2022, 10:30:34 PM

Previous topic - Next topic

Clamarc

Hi,

I'm making a batch file to include artwork in ogg audio, only they need to be in METADATA BLOCK PICTURE format,
which command to use to do this task using exiftool?

thanks

StarGeek

Exiftool cannot convert or process images.  You probably want to look at ImageMagick for that.  It also cannot edit the metadata in OGG files (see Supported File Types table).
* 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).

Clamarc

#2
 hi StarGeek,

my exiftool is the version 12.40.

The image is not in ogg, it is in jpeg on my desktop, so it would be creating the metadata block picture of the image. Still it doesn't create the metadata?

I read this information about ExifTool, did I get it wrong?

EXV files are used by Exiv2, and are basically a JPEG file without the image data, so they may be used as a metadata file to contain any information
supported by the JPEG format (EXIF, XMP, IPTC, etc.). ExifTool has full read, write and create support for this format.

"so they may be used as a metadata file to contain any information"... here would also have the metadata block picture?

thanks

Phil Harvey

"METADATA BLOCK PICTURE" is not an image format.  The images themselves are JPEG or PNG or whatever format.  This is stored in an OGG file with a header and encoded in Base64.  Here is an example of this in the ExifTool -v3 output for this sample OGG file:

  | 21) Picture (SubDirectory) -->
  |     - Tag 'METADATA_BLOCK_PICTURE' (2427 bytes):
  |         89aa: 4d 45 54 41 44 41 54 41 5f 42 4c 4f 43 4b 5f 50 [METADATA_BLOCK_P]
  |         89ba: 49 43 54 55 52 45 3d 41 41 41 41 41 77 41 41 41 [ICTURE=AAAAAwAAA]
  |         89ca: 41 70 70 62 57 46 6e 5a 53 39 71 63 47 56 6e 41 [AppbWFnZS9qcGVnA]
  |         89da: 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 [AAAAAAAAAAAAAAAA]
  |         89ea: 41 41 41 41 41 41 41 41 41 41 41 41 41 62 68 2f [AAAAAAAAAAAAAbh/]
  |         [snip 2347 bytes]
  | + [BinaryData directory, 1803 bytes]
  | | PictureType = 3
  | | - Tag 0x0000 (4 bytes, int32u[1]):
  | |     0000: 00 00 00 03                                     [....]
  | | PictureMIMEType = image/jpeg
  | | - Tag 0x0001 (10 bytes, pstr32[10]):
  | |     0008: 69 6d 61 67 65 2f 6a 70 65 67                   [image/jpeg]
  | | PictureDescription =
  | | - Tag 0x0002 (0 bytes, pstr32):
  | | PictureWidth = 0
  | | - Tag 0x0003 (4 bytes, int32u[1]):
  | |     0016: 00 00 00 00                                     [....]
  | | PictureHeight = 0
  | | - Tag 0x0004 (4 bytes, int32u[1]):
  | |     001a: 00 00 00 00                                     [....]
  | | PictureBitsPerPixel = 0
  | | - Tag 0x0005 (4 bytes, int32u[1]):
  | |     001e: 00 00 00 00                                     [....]
  | | PictureIndexedColors = 0
  | | - Tag 0x0006 (4 bytes, int32u[1]):
  | |     0022: 00 00 00 00                                     [....]
  | | PictureLength = 1761
  | | - Tag 0x0007 (4 bytes, int32u[1]):
  | |     0026: 00 00 06 e1                                     [....]
  | | Picture = .....JFIF..dd...Ducky..2...Adobed......................................[snip]
  | | - Tag 0x0008 (1761 bytes, undef[1761]):
  | |     002a: ff d8 ff e0 00 10 4a 46 49 46 00 01 02 00 00 64 [......JFIF.....d]
  | |     003a: 00 64 00 00 ff ec 00 11 44 75 63 6b 79 00 01 00 [.d......Ducky...]
  | |     004a: 04 00 00 00 32 00 00 ff ee 00 0e 41 64 6f 62 65 [....2......Adobe]
  | |     005a: 00 64 c0 00 00 00 01 ff db 00 84 00 08 06 06 06 [.d..............]
  | |     006a: 06 06 08 06 06 08 0c 08 07 08 0c 0e 0a 08 08 0a [................]
  | |     [snip 1681 bytes]


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Clamarc

hi Phil,

What I'm trying to do:
I have some mp3 files that I'm converting to ogg using ffmpeg, it turns out that ffmpeg's video codec converts what is just a
cover image in mp3 into a video stream in ogg. In this way, I convert the mp3 to ogg without the cover art and then add only
the cover I have in jpeg on ogg.

What is happening:
I found that ogg only accepts to include an art if it is in metadata block picture format. To test, I found an online site where I insert
my jpeg image and it generates the metadata block picture code of this image in .txt format and using vorbiscomment:
vorbiscomment -a -c cover.txt "audio.ogg", I can include the artwork in the ogg file as an image and not as a video stream.

What I'm looking for:
A way to use command line to do the same job the conversion site did with my jpeg image. I searched the internet and saw
something about exiv2, only it is for linux and I use Windows. Could you, with your experience, indicate or direct me to a path
where I can create a batch that generates this information from my jpeg image?

Note: after a lot of research, I found a script in Bash, which I'm trying to adapt to batch file, but as I don't have much experience
         in Bash, it has some commands in it, which I can't understand to adapt.Could I send you the script I'm adapting for you to
         help me? If yes, how do I manage to post a script on this site?... hahaha... I think I'm pushing your patience too much!

Thanks

StarGeek

I'm guessing that it might be this script?

One option would be to install Windows Subsystem for Linux  (WSL) and then you would be able to use that bash script.

Another option would be to work with this SuperUser answer.  The basic work flow would be

Base64 encode your jpeg.  PowerShell appears to have this ability built in (see this StackOverflow answer).  Otherwise you'd have to look for a program or script.  There are probably examples for every programming language, such as Python or Perl.

Save that Base64 data to a file prefixed with
;FFMETADATA1
METADATA_BLOCK_PICTURE=


Use the ffmpeg command in that first link to embed the image.
* 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).

StarGeek

I've gone and played around a bit with this and it looks like the ffmpeg solution above doesn't work.  At least I can't get it to work.  It puts the image in the wrong place.

But there is a Windows version of the VorbisComment program used in the script I linked above and a sed port is available for Windows (Unix Utils) which might make translating the bash script easier.

There's also kid3 which has a command line option, kid3-cls, which I found mentioned here, though I haven't tested it.
* 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).

Clamarc

hi Stargeek,

I had also done the ffmpeg test with the same script you sent and I couldn't either.

There is the Cygwin project, which I will test on my Windows and see if I can get
bash scripts working here.

But, anyway, having to do system emulations to be able to execute a functionality
in a certain System, decidedly, doesn't match the world we are in today, 21st century, right?!

I pray that one day, regarding the use of data manipulation, both via Windows prompt and
Linux Terminal, that we can natively create and execute any script without difficulties.
Running linux scripts on Windows and batch file scripts on Linux terminal natively, would be nice!

thanks
Clamarc