Audio File Duration and Difference using Remote URL and Piping

Started by ldadams, February 13, 2019, 12:53:42 PM

Previous topic - Next topic

ldadams

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:

./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


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

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.
* 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).

Phil Harvey

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

ldadams

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).