ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: ldadams on February 13, 2019, 12:53:42 PM

Title: Audio File Duration and Difference using Remote URL and Piping
Post by: ldadams on February 13, 2019, 12:53:42 PM
Hello,

I am seeing an issue where the output of my command is different when piping an Audio file into a command vs downloading the file and running the same command.

For instance:
Code: [Select]
./exiftool -fast test.mp3 -json -G1

[{
  "SourceFile": "test.mp3",
  "ExifTool:ExifToolVersion": 11.26,
  "System:FileName": "test.mp3",
  "System:Directory": ".",
  "System:FileSize": "7.2 MB",
  "System:FileModifyDate": "2019:02:13 17:19:06+00:00",
  "System:FileAccessDate": "2019:02:13 17:19:06+00:00",
  "System:FileInodeChangeDate": "2019:02:13 17:19:06+00:00",
  "System:FilePermissions": "rw-rw-r--",
  "File:FileType": "MP3",
  "File:FileTypeExtension": "mp3",
  "File:MIMEType": "audio/mpeg",
  "File:ID3Size": 974625,
  "MPEG:MPEGAudioVersion": 1,
  "MPEG:AudioLayer": 3,
  "MPEG:AudioBitrate": "320 kbps",
  "MPEG:SampleRate": 44100,
  "MPEG:ChannelMode": "Joint Stereo",
  "MPEG:MSStereo": "Off",
  "MPEG:IntensityStereo": "Off",
  "MPEG:CopyrightFlag": false,
  "MPEG:OriginalMedia": false,
  "MPEG:Emphasis": "None",
  "ID3v2_3:Title": "Coem On and Play Me",
  "ID3v2_3:Artist": "TEST_artist",
  "ID3v2_3:Year": "tst year",
  "ID3v2_3:Genre": "genre",
  "ID3v2_3:Album": "test album",
  "ID3v2_3:Comment": "(iTunSMPB)  00000000 000002A1 000000AD 00000000006EB1B2 00000001 0064377C 00000000 00000000 00000000 00000000 00000000 00000000",
  "ID3v2_3:PictureMIMEType": "image/PNG",
  "ID3v2_3:PictureType": "Other",
  "ID3v2_3:PictureDescription": "",
  "ID3v2_3:Picture": "(Binary data 964002 bytes, use -b option to extract)",
  "Composite:DateTimeOriginal": "tst year",
  "Composite:Duration": "0:02:44 (approx)"
}]

AND

Code: [Select]
curl -L -s '...' | ./exiftool -fast - -json -G1
[{
  "SourceFile": "-",
  "ExifTool:ExifToolVersion": 11.26,
  "File:FileType": "MP3",
  "File:FileTypeExtension": "mp3",
  "File:MIMEType": "audio/mpeg",
  "File:ID3Size": 974625,
  "MPEG:MPEGAudioVersion": 1,
  "MPEG:AudioLayer": 3,
  "MPEG:AudioBitrate": "320 kbps",
  "MPEG:SampleRate": 44100,
  "MPEG:ChannelMode": "Joint Stereo",
  "MPEG:MSStereo": "Off",
  "MPEG:IntensityStereo": "Off",
  "MPEG:CopyrightFlag": false,
  "MPEG:OriginalMedia": false,
  "MPEG:Emphasis": "None",
  "ID3v2_3:Title": "Coem On and Play Me",
  "ID3v2_3:Artist": "TEST_artist",
  "ID3v2_3:Year": "tst year",
  "ID3v2_3:Genre": "genre",
  "ID3v2_3:Album": "test album",
  "ID3v2_3:Comment": "(iTunSMPB)  00000000 000002A1 000000AD 00000000006EB1B2 00000001 0064377C 00000000 00000000 00000000 00000000 00000000 00000000",
  "ID3v2_3:PictureMIMEType": "image/PNG",
  "ID3v2_3:PictureType": "Other",
  "ID3v2_3:PictureDescription": "",
  "ID3v2_3:Picture": "(Binary data 964002 bytes, use -b option to extract)",
  "Composite:DateTimeOriginal": "tst year"
}]

What I was really after was duration value.  It didn't matter if I used the -fast flag or not.

Thanks for any advice or thoughts on this.  I am often dealing with large files that are always remote.  I would prefer not to download the file entirely if possible.

Title: Re: Audio File Duration and Difference using Remote URL and Piping
Post by: StarGeek on February 13, 2019, 01:35:52 PM
The Duration tag in question is a Composite tag (https://sno.phy.queensu.ca/~phil/exiftool/TagNames/Composite.html), which means it is calculated based on other data about the file.  It's not a value that is embedded in the file.  One of the values it needs is the FileSize, which doesn't appear to be available when you are downloading/piping from CUrl.
Title: Re: Audio File Duration and Difference using Remote URL and Piping
Post by: Phil Harvey on February 13, 2019, 01:54:42 PM
Exactly.  What StarGeek said.
Title: Re: Audio File Duration and Difference using Remote URL and Piping
Post by: ldadams on February 13, 2019, 01:59:30 PM
Thank you for the quick and helpful reply. 

I actually do have the file size from a previous process.  Is there anyway for me to supply this value to exiftool?
Title: Re: Audio File Duration and Difference using Remote URL and Piping
Post by: Phil Harvey on February 13, 2019, 02:03:05 PM
The Duration tag relies on the FileType tag.  You can't define the value of an extracted tag externally, but you could use the -userparam option to pass in a user parameter representing the file size.  However, this would require creating a user-defined Composite:Duration tag of your own that used your userParam instead of FileSize in the calculation.  I'm not sure you want to go to all this trouble.

- Phil