VideoHelp Forum
+ Reply to Thread
Results 1 to 21 of 21
Thread
  1. Member
    Join Date
    Aug 2019
    Search PM
    I want to find a fast way to determine a video file's GOP structure when no such information is present in MediaInfo.

    I managed to find the answer for files opened by VGS (Visual GOP Struct) feature of GSpot:

    For example, here is how an open GOP file looks like:



    And here is how a closed GOP looks like:



    For formats not recognized by GSpot, one can simply inspect the frame structure in AviDemux for example and base conclusions on the following:



    But there would still remain cases where this won't be enough and alternative tool of GSpot would be needed. Is there such or some other way to acquire that information?
    Last edited by Sotee; 22nd Feb 2020 at 08:48.
    Quote Quote  
  2. Member
    Join Date
    Aug 2019
    Search PM
    Elecard software? Any guide on it for what is asked in OP?
    Quote Quote  
  3. Yes, elecard streameye , or codecvisa. But they are commercial ware



    Freeware h264_parse (for AVC) or ffprobe

    ffprobe -i "input.ext" -select_streams v:0 -show_frames 1>ffprobe.txt

    Look for pict_type=I, but key_frame=0 . The presence of this indicates open GOP

    An IDR frame will have pict_type=I, but key_frame=1

    It's not user friendly method, but use your text editor and search for string " pict_type=I" and check out the key_frame value, you need to check a few at least.


    For example, this frame indicates open GOP

    media_type=video
    stream_index=0
    key_frame=0
    pkt_pts=72694944
    pkt_pts_time=807.721600
    pkt_dts=72694944
    pkt_dts_time=807.721600
    best_effort_timestamp=72694944
    best_effort_timestamp_time=807.721600
    pkt_duration=3753
    pkt_duration_time=0.041700
    pkt_pos=21373440
    pkt_size=345851
    width=1920
    height=1080
    pix_fmt=yuv420p
    sample_aspect_ratio=1:1
    pict_type=I
    coded_picture_number=65
    display_picture_number=0
    interlaced_frame=0
    top_field_first=0
    repeat_pict=0
    color_range=unknown
    color_space=unknown
    color_primaries=unknown
    color_transfer=unknown
    chroma_location=left
    Quote Quote  
  4. Member
    Join Date
    Aug 2019
    Search PM
    Originally Posted by poisondeathray View Post
    pict_type=I, but key_frame=0 . The presence of this indicates open GOP
    This is unreliable. I just made a h265 file (shown in MediaInfo as open-gop) with 44 pict_type=I matches and not a single one of them has key_frame=0.
    Quote Quote  
  5. Originally Posted by Sotee View Post
    Originally Posted by poisondeathray View Post
    pict_type=I, but key_frame=0 . The presence of this indicates open GOP
    This is unreliable. I just made a h265 file (shown in MediaInfo as open-gop) with 44 pict_type=I matches and not a single one of them has key_frame=0.
    This does not necessarily indicate anything

    Mediainfo is unreliable. It just tells you the encoding settings used. The metadata. Not what the actual stream is

    If you enable Open gop for an encoder, it does not necessarily mean you have open gops. They are only placed when the encoder thinks it's beneficial to do so and you have not surpassed the max keyframe interval setting . You would need to verify with a stream analyzer

    But ffprobe used to be unreliable for AVC too ; but I'll check it with h265
    Quote Quote  
  6. For HEVC , it seems to detect some, but it is classifying in them only under I,P,B. Technically not entirely correct

    One problem is there are several additional frame types of frames in HEVC, not just "I" vs "i" and P, B for AVC
    http://www.hevcbook.de/hevc-picture-types/

    The equivalent for an AVC IDR frame is an "IRAP" in HEVC . But there are several other subtypes of "I" frames for HEVC.

    ffprobe is classifying in them only under I,P,B, it doesn't exactly distinguish the subtype of "I". But it identified a RADL as an I non key . So it does not label them "all" as key



    A free hevc analyzer would be hevcesbrowser , this matches the results of commercial analyzers
    Quote Quote  
  7. Member
    Join Date
    Aug 2019
    Search PM
    Originally Posted by poisondeathray View Post
    it does not necessarily mean you have open gops.
    Yes, but I tested it with the file from OP and the result was negative too. I would avoid the ffprobe method.

    Hevcesbrowser loading of files is too slow in the cases where it doesn't crash for me.

    Any idea what to look for in Elecard?
    Quote Quote  
  8. Image
    [Attachment 52070 - Click to enlarge]

    For MPEG-2 files, the left text info panel will state whether the file is open or closed GOP.

    Image
    [Attachment 52071 - Click to enlarge]

    For MPEG-4 files, i don't see any info panel that states this.
    Instead, I have to scroll through the IPB frames to verify (notice when I click on a P/B frame, it'll indicate which other frames it refers to).
    CloseGOP means the PB frames only refer to the frames between surrounding I frames.
    OpenGOP means the PB frames can refer to frames outside the surrounding I frames, AFIK.
    Quote Quote  
  9. Member
    Join Date
    Aug 2019
    Search PM
    Originally Posted by babygdav View Post
    when I click on a P/B frame, it'll indicate which other frames it refers to
    Yes, this would do the trick. Sadly the evaluation version has a frame limit, so I have to search for something else.
    Quote Quote  
  10. Member
    Join Date
    Aug 2019
    Search PM
    I asked in Avidemux forums and the solution turned out to be pretty easy:

    You could open the shell in Avidemux ("Tools" --> "Scripting Shell") and run the command:

    for frame in range(0,300): Editor().printTiming(frame)
    to inspect the first 300 frames.

    On Windows, the output is directed to the Avidemux log file admlog.txt in %localappdata%\avidemux\ directory.

    If you see a line with "B" (like "B-frame") directly following a line with "I" (like "intra" or "IDR", Avidemux doesn't communicate the difference between the both, unfortunately), the stream is encoded in open GOP mode.
    Quote Quote  
  11. Originally Posted by Sotee View Post
    I asked in Avidemux forums and the solution turned out to be pretty easy:

    You could open the shell in Avidemux ("Tools" --> "Scripting Shell") and run the command:

    for frame in range(0,300): Editor().printTiming(frame)
    to inspect the first 300 frames.

    On Windows, the output is directed to the Avidemux log file admlog.txt in %localappdata%\avidemux\ directory.

    If you see a line with "B" (like "B-frame") directly following a line with "I" (like "intra" or "IDR", Avidemux doesn't communicate the difference between the both, unfortunately), the stream is encoded in open GOP mode.



    A B preceding an I in not specific for open GOP. You can have a B preceding an I with a closed GOP too (in that case for AVC it's actually an IDR)

    Did you test it? That avidemux script method is not accurate for AVC. It misidentifies some "i" frames as P and lists some true IDR frames with preceding B's (but that is a valid configuration for a closed GOP) . ie. It does not match stream analyzers

    For HEVC, it's more complicated. You can have open GOP's with leading b-frames and still cut before a CRA . That's still a valid bitstream . You don't need an IDR(IRAP) type "I" to cut. What you need to know (in the context of "is it safe to cut here or not") is if there are references and their relationships
    Quote Quote  
  12. Member
    Join Date
    Aug 2019
    Search PM
    Originally Posted by poisondeathray View Post
    avidemux script method is not accurate
    This is not Avidemux method - it's universal method using Avidemux to determine the frame types. If you inspect the stream with another program you can still deduce the GOP type following the rule B after I in stream/coded order, which is essentially what I quoted you in the other thread before starting this one:

    For each I-frame in the sequence, search packets after it and note AVPacket.pos and AVPacket.pts. If B(pos) > I(pos) but B(pts) < I(pts), you have open GOP, else closed GOP.
    Quote Quote  
  13. Originally Posted by Sotee View Post
    Originally Posted by poisondeathray View Post
    avidemux script method is not accurate
    This is not Avidemux method - it's universal method using Avidemux to determine the frame types. If you inspect the stream with another program you can still deduce the GOP type following the rule B after I in stream/coded order, which is essentially what I quoted you in the other thread before starting this one:

    For each I-frame in the sequence, search packets after it and note AVPacket.pos and AVPacket.pts. If B(pos) > I(pos) but B(pts) < I(pts), you have open GOP, else closed GOP.

    Yes, that last quote is correct and is the universal definition. B comes after the I in coded order, but precedes the I in display order


    I said "avidemux script method is not accurate". ie. it does not necessarily correctly identify frames .

    For AVC, it might not be significant in the context of cutting, unless it misidentifies an "i" frame as an "IDR" frame. So far that method is misidentifying "i" frames as "P" frames, but you wouldn't cut there normally anyways if you were "cutting on keyframes"
    Quote Quote  
  14. I'm looking at some AVC blu-rays, and because avidemux does not correctly identify the "i" frames or positions , you would incorrectly deduce that it was closed GOP . When in fact, there are open GOP's scattered around with closed GOP's, it just doesn't see the open ones because it can't identify the "i" correctly

    But in the cutting context, it seems to get the IDR frames correct so far, at least with the most recent beta build . In the past, many softwares would mixup "i" and "IDR", and of course that is a disaster in the cutting context
    Quote Quote  
  15. You can also have sequences like I1_P1_I2_P2 where P2 references P1. Imagine a horror movie that flashes some scary picture for exactly 1 frame only for the horror effect. But AFAIK this is not allowed on Blu-Ray so you should be safe with such sources at least.
    Quote Quote  
  16. Originally Posted by poisondeathray View Post
    Originally Posted by Sotee View Post
    Originally Posted by poisondeathray View Post
    pict_type=I, but key_frame=0 . The presence of this indicates open GOP
    This is unreliable. I just made a h265 file (shown in MediaInfo as open-gop) with 44 pict_type=I matches and not a single one of them has key_frame=0.
    This does not necessarily indicate anything

    Mediainfo is unreliable. It just tells you the encoding settings used. The metadata. Not what the actual stream is

    If you enable Open gop for an encoder, it does not necessarily mean you have open gops. They are only placed when the encoder thinks it's beneficial to do so and you have not surpassed the max keyframe interval setting . You would need to verify with a stream analyzer

    But ffprobe used to be unreliable for AVC too ; but I'll check it with h265
    ok for better video quality which is better open or closed and why?
    Quote Quote  
  17. Originally Posted by Takashi View Post
    ok for better video quality which is better open or closed and why?
    In general , for a given bitrate, - open gop - because it has the option to reference other related frames that would otherwise be inaccessable due to an IDR delimiter. It can help reduce "keyframe pumping" or noticable differences in quality between the last frame of the current GOP and the 1st frame of the next GOP
    Quote Quote  
  18. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    Originally Posted by Takashi View Post
    ok for better video quality which is better open or closed and why?
    Open, unless the spec/format demands closed (example = DVD-Video).
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  19. Originally Posted by lordsmurf View Post
    unless the spec/format demands closed (example = DVD-Video).
    DVD-video, blu-ray only need closed GOPs for chapter points. The majority of GOPs are usually open
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!