Duration reported wrong ffprobe vs exiftool

Started by theprof, November 02, 2024, 03:19:24 PM

Previous topic - Next topic

theprof

This is on Debian Testing Linux with EXIFTool version 12.76 running under PHP 8.2.24 CLI mode shell executing EXIFTool.

This is the raw JSON output from FFProbe (command ffprobe -v error -show_format -show_streams -print_format json "$source"):
Array
(
    [streams] => Array
        (
            [0] => Array
                (
                    [index] => 0
                    [codec_name] => mp2
                    [codec_long_name] => MP2 (MPEG audio layer 2)
                    [codec_type] => audio
                    [codec_tag_string] => [0][0][0][0]
                    [codec_tag] => 0x0000
                    [sample_fmt] => s16p
                    [sample_rate] => 32000
                    [channels] => 1
                    [channel_layout] => mono
                    [bits_per_sample] => 0
                    [initial_padding] => 0
                    [id] => 0x1c0
                    [r_frame_rate] => 0/0
                    [avg_frame_rate] => 0/0
                    [time_base] => 1/90000
                    [start_pts] => 9900
                    [start_time] => 0.110000
                    [duration_ts] => 327240
                    [duration] => 3.636000
                    [bit_rate] => 64000
                    [disposition] => Array
                        (
                            [default] => 0
                            [dub] => 0
                            [original] => 0
                            [comment] => 0
                            [lyrics] => 0
                            [karaoke] => 0
                            [forced] => 0
                            [hearing_impaired] => 0
                            [visual_impaired] => 0
                            [clean_effects] => 0
                            [attached_pic] => 0
                            [timed_thumbnails] => 0
                            [non_diegetic] => 0
                            [captions] => 0
                            [descriptions] => 0
                            [metadata] => 0
                            [dependent] => 0
                            [still_image] => 0
                            [multilayer] => 0
                        )

                )

            [1] => Array
                (
                    [index] => 1
                    [codec_name] => mpeg1video
                    [codec_long_name] => MPEG-1 video
                    [codec_type] => video
                    [codec_tag_string] => [0][0][0][0]
                    [codec_tag] => 0x0000
                    [width] => 640
                    [height] => 480
                    [coded_width] => 0
                    [coded_height] => 0
                    [closed_captions] => 0
                    [film_grain] => 0
                    [has_b_frames] => 1
                    [sample_aspect_ratio] => 1:1
                    [display_aspect_ratio] => 4:3
                    [pix_fmt] => yuv420p
                    [level] => -99
                    [color_range] => tv
                    [chroma_location] => center
                    [field_order] => progressive
                    [refs] => 1
                    [id] => 0x1e0
                    [r_frame_rate] => 50/1
                    [avg_frame_rate] => 25/1
                    [time_base] => 1/90000
                    [start_pts] => 9900
                    [start_time] => 0.110000
                    [duration_ts] => 351000
                    [duration] => 3.900000
                    [bit_rate] => 104857200
                    [extradata_size] => 76
                    [disposition] => Array
                        (
                            [default] => 0
                            [dub] => 0
                            [original] => 0
                            [comment] => 0
                            [lyrics] => 0
                            [karaoke] => 0
                            [forced] => 0
                            [hearing_impaired] => 0
                            [visual_impaired] => 0
                            [clean_effects] => 0
                            [attached_pic] => 0
                            [timed_thumbnails] => 0
                            [non_diegetic] => 0
                            [captions] => 0
                            [descriptions] => 0
                            [metadata] => 0
                            [dependent] => 0
                            [still_image] => 0
                            [multilayer] => 0
                        )

                    [side_data_list] => Array
                        (
                            [0] => Array
                                (
                                    [side_data_type] => CPB properties
                                    [max_bitrate] => 0
                                    [min_bitrate] => 0
                                    [avg_bitrate] => 0
                                    [buffer_size] => 524288
                                    [vbv_delay] => -1
                                )

                        )

                )

        )

    [format] => Array
        (
            [filename] => /mnt/media/file.mp4
            [nb_streams] => 2
            [nb_programs] => 0
            [nb_stream_groups] => 0
            [format_name] => mpeg
            [format_long_name] => MPEG-PS (MPEG-2 Program Stream)
            [start_time] => 0.110000
            [duration] => 3.900000
            [size] => 1429472
            [bit_rate] => 2932250
            [probe_score] => 26
        )

)

This is the raw JSON output from EXIFTool (command exiftool -F -q -q -f -r -json -api QuickTimeUTC \
                    -api LargeFileSupport -api ignoretags=all \
                    -FileType -CompressorName -CompressorID -FileTypeExtension \
                    -MIMEType -Duration# -CoverArt -CreateDate -FileModifyDate \
                    -FileSize \
                    "$source")
Array
(
    [SourceFile] => /mnt/media/file.mp4
    [FileType] => MPEG
    [CompressorName] => -
    [CompressorID] => -
    [FileTypeExtension] => mpg
    [MIMEType] => video/mpeg
    [Duration] => -
    [CoverArt] => -
    [CreateDate] => -
    [FileModifyDate] => 2024:11:01 15:55:28-04:00
    [FileSize] => 1429 kB
)

Why is EXIFTool reporting no duration meanwhile FFProbe is reporting 3.9 seconds duration?

StarGeek

ffprobe analyzes the actual streams while exiftool only reads the header metadata. See here.

Obviously, something is wrong with the header data on that file or exiftool can't read it properly. If you can provide a sample, Phil might be able to figure out the problem.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

theprof

Quote from: StarGeek on November 02, 2024, 03:34:44 PMffprobe analyzes the actual streams while exiftool only reads the header metadata. See here.

Obviously, something is wrong with the header data on that file or exiftool can't read it properly. If you can provide a sample, Phil might be able to figure out the problem.

Ah ok.

It's okay if duration is off.

However, it is critical that I have an accurate "Codec Name" (HVC1, HEV1, AVC1 etc) and "Container" (MKV, MOV, AVI, JPG). I'm using CompressorID for the Codec and FileType for the Container......is it possible for these to be ever off?

StarGeek

I don't know. I don't recall it coming up in these forums before. But I would probably give priority to ffprobe in that case. exiftool is better for the metadata, as I don't recall ffprobe getting into the details as to the group locations, but it would be better for the stream data as it actually reads the streams.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

Quote from: theprof on November 02, 2024, 03:54:57 PMit is critical that I have an accurate "Codec Name" (HVC1, HEV1, AVC1 etc) and "Container" (MKV, MOV, AVI, JPG). I'm using CompressorID for the Codec and FileType for the Container......is it possible for these to be ever off?

It is certainly possible for any metadata to be "off", but I would guess that a file with an incorrect CompressorID wouldn't be playable since I'm thinking this would be used by the video player.

The FileType is less likely to be wrong, and if it is then the file is more likely to be unusable.

- 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 ($).