Author Topic: Audio File Duration and Difference using Remote URL and Piping  (Read 256 times)

ldadams

  • Newbie
  • *
  • Posts: 2
Audio File Duration and Difference using Remote URL and Piping
« 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.


StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2668
Re: Audio File Duration and Difference using Remote URL and Piping
« Reply #1 on: February 13, 2019, 01:35:52 PM »
The Duration tag in question is a Composite tag, 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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14937
    • ExifTool Home Page
Re: Audio File Duration and Difference using Remote URL and Piping
« Reply #2 on: February 13, 2019, 01:54:42 PM »
Exactly.  What StarGeek said.
...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 ($).

ldadams

  • Newbie
  • *
  • Posts: 2
Re: Audio File Duration and Difference using Remote URL and Piping
« Reply #3 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?

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14937
    • ExifTool Home Page
Re: Audio File Duration and Difference using Remote URL and Piping
« Reply #4 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
...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 ($).