VideoHelp Forum
+ Reply to Thread
Results 1 to 10 of 10
Thread
  1. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    Hello,

    I was looking to cut on an MPEG-2 encoded file (DVD). I was trying to find the IDR frames to make a clean cut. For h264 input I use Selur's FrameCounter application. His website lists support for MPEG-2 files (raw = .m2v). When I attempt to use that (syntax: FrameCounter input.m2v list 2> output.txt), the only output I get is "Frame count analyse at [x] of [total]" repeated for each frame. But it does not provide any information about the frame, as it does using the same syntax with h264 input. Is there separate syntax I should use, or a different program that would work better to identify frame types for this input?
    Quote Quote  
  2. I can't address your question (not clear to me as MPEG-2 has no IDR) - you can try to use something like:
    Code:
    @set name=%~1
    @ffprobe -hide_banner -v 32 -stats -y -skip_frame nokey -i "%name%" -select_streams v:0 -print_format compact -show_entries "frame=key_frame,pkt_pos,pkt_pts_time" > "%~n1_.txt"
    Quote Quote  
  3. The 'list' parameter in FrameCounter is only implemented for H.264.
    pandys call should help, since it should output all key frames.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  4. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    Originally Posted by pandy View Post
    I can't address your question (not clear to me as MPEG-2 has no IDR) - you can try to use something like:
    Code:
    @set name=%~1
    @ffprobe -hide_banner -v 32 -stats -y -skip_frame nokey -i "%name%" -select_streams v:0 -print_format compact -show_entries "frame=key_frame,pkt_pos,pkt_pts_time" > "%~n1_.txt"
    Ah, thanks! I wasn't sure if MPEG-2 had IDR frames, but I figured there were certain key frames that needed to be cut on. I am using windows command shell. I can figure out how to do the ffprobe command you quoted, but how would I begin by setting the name variable. I imagine that if I put that as the first command in the shell, it won't stick for the subsequent ffprobe command. If I turned this into a batch script, would that work?
    Quote Quote  
  5. what pandy posted was code for a batch script, so yes it should work in a batch script
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  6. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    Originally Posted by Selur View Post
    what pandy posted was code for a batch script, so yes it should work in a batch script
    Perfect, thanks!
    Quote Quote  
  7. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    OK, one more question, sorry. I ran the script. All my pkt_pts_time came back as "N/A." What unit are the pkt_pos units in? I get really large numbers, so I know that's not frame number.

    This is a sample of my output. How do I decipher frame number for the corresponding keyframe?
    frame|key_frame=1|pkt_pts_time=N/A|pkt_pos=0side_data|

    frame|key_frame=1|pkt_pts_time=N/A|pkt_pos=11208side_data|

    frame|key_frame=1|pkt_pts_time=N/A|pkt_pos=23184side_data|
    Quote Quote  
  8. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    Originally Posted by Selur View Post
    The 'list' parameter in FrameCounter is only implemented for H.264.
    pandys call should help, since it should output all key frames.
    Gotcha. Love your program, by the way
    Quote Quote  
  9. Originally Posted by Travillion View Post
    OK, one more question, sorry. I ran the script. All my pkt_pts_time came back as "N/A." What unit are the pkt_pos units in? I get really large numbers, so I know that's not frame number.

    This is a sample of my output. How do I decipher frame number for the corresponding keyframe?
    frame|key_frame=1|pkt_pts_time=N/A|pkt_pos=0side_data|

    frame|key_frame=1|pkt_pts_time=N/A|pkt_pos=11208side_data|

    frame|key_frame=1|pkt_pts_time=N/A|pkt_pos=23184side_data|
    As you are using elementary stream this may be some issue for ffmpeg (and i think all open source based on same code programs) seem some container is required to display packet PTS time, packet position should be expressed as byte offset to start of file.
    And usage is quite simple - type your script name and file to be exercised as parameter to script so 'scriptname.cmd filename.m2v'
    I use Total Commander and this is from my perspective ctrl + enter on batch file SPACE ctrl + enter on filename - old habits from Norton Commander times.

    To understand ffmpeg you may wish to use very detailed information script - it can create txt and csv files - time consuming as each frame is reported

    Code:
    @set name=%~1
    @ffprobe -hide_banner -v 32 -stats -y -i "%name%" -select_streams v:0 -print_format compact -show_entries frame > "%~n1.txt"
    @echo entry_type,media_type,stream_index,key_frame,pkt_pts,pkt_pts_time,pkt_dts,pkt_dts_time,best_effort_timestamp,best_effort_timestamp_time,pkt_duration,pkt_duration_time,pkt_pos,pkt_size,width,height,pix_fmt,sample_aspect_ratio,pict_type,coded_picture_number,display_picture_number,interlaced_frame,top_field_first,repeat_pict,color_range,color_space,color_primaries,color_transfer,chroma_location  > "%~n1.csv"
    @ffprobe -hide_banner -v 32 -stats -y -i "%name%" -select_streams v:0 -print_format csv -show_entries frame >> "%~n1.csv"
    Quote Quote  
  10. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    Originally Posted by pandy View Post
    Originally Posted by Travillion View Post
    OK, one more question, sorry. I ran the script. All my pkt_pts_time came back as "N/A." What unit are the pkt_pos units in? I get really large numbers, so I know that's not frame number.

    This is a sample of my output. How do I decipher frame number for the corresponding keyframe?
    frame|key_frame=1|pkt_pts_time=N/A|pkt_pos=0side_data|

    frame|key_frame=1|pkt_pts_time=N/A|pkt_pos=11208side_data|

    frame|key_frame=1|pkt_pts_time=N/A|pkt_pos=23184side_data|
    As you are using elementary stream this may be some issue for ffmpeg (and i think all open source based on same code programs) seem some container is required to display packet PTS time, packet position should be expressed as byte offset to start of file.
    And usage is quite simple - type your script name and file to be exercised as parameter to script so 'scriptname.cmd filename.m2v'
    I use Total Commander and this is from my perspective ctrl + enter on batch file SPACE ctrl + enter on filename - old habits from Norton Commander times.

    To understand ffmpeg you may wish to use very detailed information script - it can create txt and csv files - time consuming as each frame is reported

    Code:
    @set name=%~1
    @ffprobe -hide_banner -v 32 -stats -y -i "%name%" -select_streams v:0 -print_format compact -show_entries frame > "%~n1.txt"
    @echo entry_type,media_type,stream_index,key_frame,pkt_pts,pkt_pts_time,pkt_dts,pkt_dts_time,best_effort_timestamp,best_effort_timestamp_time,pkt_duration,pkt_duration_time,pkt_pos,pkt_size,width,height,pix_fmt,sample_aspect_ratio,pict_type,coded_picture_number,display_picture_number,interlaced_frame,top_field_first,repeat_pict,color_range,color_space,color_primaries,color_transfer,chroma_location  > "%~n1.csv"
    @ffprobe -hide_banner -v 32 -stats -y -i "%name%" -select_streams v:0 -print_format csv -show_entries frame >> "%~n1.csv"
    Ahh....I was using the elementary stream because that is what I'm used to using with FrameCounter. I can use a muxed version no problem. Let me try that. Thanks!
    Quote Quote  



Similar Threads

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