My system is Windows and I use Cygwin to run bash and shell file. Check a script, see the link below, which according to its author creates the metadata of an image to be attached to the ogg file, it happens that the script is generating incomplete data.
I did some tests with the first script posted by @Gaff here:Embed album art in OGG through command line in linux that do not generate the metadata correctly, see the tests below:
Metadata block picture results according to defined option in the $EASYTAG variable of the script.
Note:
When we run the script without the -e parameter at the end, the $EASYTAG variable will have the value of N and when we run the script with the -e parameter at the end, the $EASYTAG variable will have the Y value.
Script execution command without -e at the end :
sh oggart.sh "audio.ogg" "cover.jpg"
Output ffprobe in audio file with option $EASYTAG variable = N, generated by the script:
[ogg @ 0000023748f0f300] Invalid picture type: -2555936.
[ogg @ 0000023748f0f300] Could not read mimetype from an attached picture.
Input #0, ogg, from 'audio.ogg':
Duration: 00:03:26.60, start: 0.000000, bitrate: 402 kb/s
Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 320 kb/s
Metadata:
encoder : Lavc59.12.100 libvorbis
album : CMG Clássicos Pop Rock Nacionais
artist : Lobão
date : 1988
genre : Clássico Pop Rock Nacional
TKEY : E m
title : Cuidado!
Script execution command with -e at the end :
sh oggart.sh "audio.ogg" "cover.jpg" -e
Output ffprobe in audio file with option $EASYTAG variable = Y, generated by the script:
Input #0, ogg, from 'audio.ogg':
Duration: 00:03:26.60, start: 0.000000, bitrate: 402 kb/s
Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 320 kb/s
Metadata:
encoder : Lavc59.12.100 libvorbis
album : CMG Clássicos Pop Rock Nacionais
artist : Lobão
date : 1988
genre : Clássico Pop Rock Nacional
TKEY : E m
title : Cuidado!
COVERART : /9j/4AAQSkZJRgABAQEASABIAAD/4ROiRXhpZgAASUkqAAgAAAACADIBAgAUAAAAJ
gAAAGmHBAABAAAAOgAAAEAAAAAyMDE5OjEwOjE4IDEzOjU4OjU5AAAAAAAAAAMAAw
EEAAEAAAAGAAAAAQIEAAEAAABqAAAAAgIEAAEAAAAwEwAAAAAAAP/Y/+AAEEpGSUY
AAQEAAAEAAQAA/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBg
In $EASYTAG = N show:
[ogg @ 0000023748f0f300] Invalid picture type: -2555936.
[ogg @ 0000023748f0f300] Could not read mimetype from an attached picture.
In $EASYTAG = Y, does not show an error message, but includes the COVERART in a Metadata field with incomplete data:
COVERART : /9j/4AAQSkZJRgABAQEASABIAAD/4ROiRXhpZgAASUkqAAgAAAACADIBAgAUAAAAJ
gAAAGmHBAABAAAAOgAAAEAAAAAyMDE5OjEwOjE4IDEzOjU4OjU5AAAAAAAAAAMAAw
EEAAEAAAAGAAAAAQIEAAEAAABqAAAAAgIEAAEAAAAwEwAAAAAAAP/Y/+AAEEpGSUY
AAQEAAAEAAQAA/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBg
Note: The COVERAT field shows only the first 255 characters of the generated metadata block picture... this may be happening precisely because of the lack information in the data block related to the identification of the file, that is in its header, where the program identifies the record and inserts it correctly as a cover art in the file.
The ogg metadata block picture structure appears to be the same as flac's.
Script is generating incomplete metadata block picture, seems to be missing metadata header. Note below, mainly, the information in --add padding. The script doesn't seem to be considering the 4 bytes when generating the metadata block picture.
--import-picture-from={FILENAME|SPECIFICATION}
Import a picture and store it in a PICTURE metadata block.
See the flac option --picture for an explanation of the SPECIFICATION syntax.
--add-padding=#
Add a padding block of the given length (in bytes). The overall length of the new
block will be 4 + length; the extra 4 bytes is for the metadata block header.
Note: Maybe that's the problem with your file not being generated with the header.
--dont-use-padding
By default metaflac tries to use padding where possible to avoid rewriting the entire
file if the metadata size changes. Use this option to tell metaflac to not take
advantage of padding this way.
Note: Another possibility of metadata generation error, look here: https://github.com/taglib/taglib
Is there no ffmpeg function or program that does the conversion correctly so that it can be used in a batch file?
@Tom Yan, first i wanted to thank you for your post, because it was exactly what I was looking for many days, thank you!
I followed your step by step to run vorbis_ca, but I had some problems:
Step 1:
I created a folder called Vorbis in the following path:
C:\Users\CMG\Vorbis
I copied the vorbis_ca.c into the Vorbis folder and compiled the file:
gcc vorbis_ca.c -o vorbis_ca.exe
I changed the path to my desktop, which is where the image is on my PC:
cd "C:/Users/CMG/Desktop"
I ran the file command on the image:
file cover.jpeg
Output file command:
Exif Standard: [TIFF image data, little-endian, direntries=2, datetime=2019:10:18 13:58:59], baseline,
precision 8, 1018x1023, components 3
Step 2:
I ran the ./vorbis_ca command:
$ ./vorbis_ca 1018 1023 cover.jpeg | hexdump -C
Output ./vorbis_ca command:
-bash: ./vorbis_ca: No such file or directory
so i tried:
"C:/Users/CMG/Vorbis/"./vorbis_ca 1018 1023 cover.jpeg | hexdump -C
Output ./vorbis_ca command inserting full path:
00000000 00 00 00 03 00 00 00 09 69 6d 61 67 65 2f 6a 70 |........image/jp|
00000010 67 00 00 00 00 00 00 03 fa 00 00 03 ff 00 00 00 |g...............|
00000020 18 00 00 00 00 00 04 39 24 |.......9$|
00000029
./vorbis_ca only runs when I put the full path.
Note:
When I compiled the vorbis_ca.c which is in the folder in the path: C:\Users\CMG\Vorbis I can't run the
generated ./vorbis_ca in any location, how to make ./vorbis_ca run without me having to put the full path?
eg. in the file cover.jpeg command, I didn't need to put the full path of it for it to work.
Step 3:
Run vorbiscomment command: note that I had to put the full path of ./vorbis_ca in this command.
$ vorbiscomment -w -t "METADATA_BLOCK_PICTURE=$(("C:/Users/CMG/Vorbis/"./vorbis_ca 1018 1023 cover.jpeg; cat cover.jpeg) | base64 -w 0)" "audio_cover.ogg"
Output vorbiscomment command:
-bash: /cygdrive/c/vorbis-tools-master/bin/x64/vorbiscomment: Argument list too long
Why did the above message appear when I ran vorbiscomment?
Another question: in Step 2, I ran the command ./vorbis_ca 1018 1023 cover.jpeg | hexdump -C and your last command again has the
./vorbis_ca 1018 1023 cover.jpeg. This command needs to be run twice, or did you just show it in detail as an example?
That is, the official command is the last command, correct?