Opened 4 months ago

Last modified 4 months ago

#7702 new defect

Incorrect video frame reporting

Reported by: budman1 Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:
Create blankclip 3600 frames long with time and frame number hardcoded in it. Cut at I-frame 1850 (GOP 50).

FFprobe states the video starts at complete frame 1852 'B' frame but all video viewers all show 1850 I-frame . FFprobe also states first frame is time code pkt_pts_time is 0.000000 and 'B' frame.

Creating -F image2 will create nothing but frame 1852.

How can this be correct if players show frame 1850 and 1851 starting?

Attachments (7)

G50_30_Test_Pattern_Final0_0.mp4 (43.3 KB) - added by budman1 4 months ago.
BlankClip? 3600 frames 640x480, Hardcoded time and frame numbers
final_1st_frame.jpg (27.9 KB) - added by budman1 4 months ago.
Final 1st Frame
final_ffplay.jpg (24.8 KB) - added by budman1 4 months ago.
ffplay 1st frame
final_viewer.jpg (31.7 KB) - added by budman1 4 months ago.
Potplayer (VLC) view first frame
ffprobe_final.jpg (46.2 KB) - added by budman1 4 months ago.
'B' frame 0
ffmpeg log.rtf (8.4 KB) - added by budman1 4 months ago.
scripts and console output
ffmpeg log.txt (7.5 KB) - added by budman1 4 months ago.
text file of command sequence

Download all attachments as: .zip

Change History (15)

Changed 4 months ago by budman1

BlankClip? 3600 frames 640x480, Hardcoded time and frame numbers

comment:1 Changed 4 months ago by cehoyos

  • Keywords Key frame dts pts removed

Please test current FFmpeg git head and provide the command you tested together with the complete, uncut console output to make this a valid ticket.

Changed 4 months ago by budman1

Final 1st Frame

Changed 4 months ago by budman1

ffplay 1st frame

Changed 4 months ago by budman1

Potplayer (VLC) view first frame

comment:2 Changed 4 months ago by budman1

Updating to ffmpeg version N-93022-g260f1960e7 solved player problem but still extracts wrong frame


create Blank clip, no sound:
BlankClip?(length=3600, width=640, height=480, fps=30, color=$000000)

create blank clip (GOP=50, FPS=30)with Frame type, Frame number and time embedded using Avisynth and FFMpeg:

Avisynth script (test.avs):
FFmpegSource2("C:\Users\Bud\Desktop\G50_30_Test Pattern.mp4").Crop(0,0,-0,-0).LanczosResize?(640,480)
ScriptClip?(Last, """Subtitle("[ "+Chr(FFPICT_TYPE)+" ]", size=(Height*56.0/720), align=2)""", after_frame=true)
Subtitle("Test_Pattern.mp4", x=295, y=240, font="Arial", size=24, text_color=$ff0000, align=3)
ShowFrameNumber?(scroll=true, x=10, y=27, font="Arial", size=24, text_color=$ffff80)
ShowTime?(x=72, y=44, font="Arial", size=24, text_color=$ffff80)
ShowSMPTE(fps=25, x=68, y=61, font="Arial", size=24, text_color=$ffff80)

FFMpeg script:
ffmpeg -i test.avs -an -c:v libx264 -crf 22 -g 50 -r 30 "G50_30_Test_Pattern.mp4"

Cut at frame 1848 (I-Frame with new file frame 0 dts 0.06616, 1st cut):
ffmpeg -i "G50_30_Test_Pattern.mp4" -ss 61.600000 -vframes 1750 -c:v copy -c:a copy -y "C:\Users\Bud\Desktop\1852\G50_30_Test_Pattern_First.mp4"

check dts/pts (gives dts time 0.066016):
ffprobe -i "C:\Users\Bud\Desktop\G50_30_Test_Pattern_First.mp4" -v quiet -select_streams v -show_frames -show_entries frame=pkt_pts_time -read_intervals %+6 -of csv

In order to get 0.000000 dts (dts * 0.667 = 0.044033)
ffmpeg -nostats -loglevel 0 -ss 0.044033 -i "C:\Users\Bud\Desktop\G50_30_Test_Pattern_First.mp4" -vframes 1750 -c:v copy -c:a copy -y "C:\Users\Bud\Desktop\G50_30_Test_Pattern_Final.mp4"

Check dts/pts (gives dts time 0.000000):
ffprobe -i "C:\Users\Bud\Desktop\G50_30_Test_Pattern_Final.mp4" -v quiet -select_streams v -show_frames -show_entries frame=pkt_pts_time -read_intervals %+6 -of csv

ffplay script to view (see final_ffplay.jpg):
DirectShowSource?("C:\Users\Bud\Desktop\1852\G50_30_Test_Pattern_Final.mp4").Crop(0, 0, -0, -0)x = float(Width) / float(Height)
last.LanczosResize?(round(x * 480.0 / 4.0) * 4, 480).trim(0, -1750)
ShowFrameNumber?(offset=0,scroll=true, x=10, y=127, font="Arial", size=24, text_color=$ffff80)
ShowTime?(offset_f=0,x=72, y=144, font="Arial", size=24, text_color=$ffff80)

extract first frame as xxx.jpg (final_1st_frame.jpg):
ffmpeg -i "C:\Users\Bud\Desktop\1852\G50_30_Test_Pattern_Final.mp4" -ss 0.000000 -f image2 -q:v 1 -vf scale=640:-2,"drawtext=fontfile=c:/Windows/Fonts/Arial.ttf:text='0.000000':fontsize=30:box=1:x=(w-tw)/2:y=h-(2*lh),drawtext=fontfile=c:/Windows/Fonts/Arial.ttf:text='0:1':fontsize=30:box=1:x=(w-tw)/2:y=h-(2*lh)-30" -vframes 1 -y "C:\Users\Bud\Desktop\TrimNMerge\TrimNMerge\bin\Debug\work\Thumb_1.jpg

Changed 4 months ago by budman1

'B' frame 0

comment:3 Changed 4 months ago by cehoyos

Please provide the ffmpeg command line you tested together with the complete, uncut console output to make this a valid ticket.

Changed 4 months ago by budman1

scripts and console output

comment:4 Changed 4 months ago by budman1

Uploaded 'FFmpeg log.rtf' (ffmpeg command line tested together with the complete, uncut console output to make this a valid ticket.)

comment:5 follow-up: Changed 4 months ago by cehoyos

Why??

comment:6 Changed 4 months ago by budman1

You are kidding right? I succeeded in creating a segment that has frame 0 dts/pts timecode of 0.000000 for better merging. Players play segment starting with frame 0 (1850). You cannot extract frame 0 (1850/1851) because ffprobe displays the first frame as being crystal clear, complete frame, audio in sync 'B' frame.

Bug is: Players view frame 0/1 (1850/1851) so they are included. ffmpeg cannot extract those frames because according to ffprobe they do not exist!

One more item: 25 FPS and 29.97 FPS work correctly. 30 FPS does not.

comment:7 in reply to: ↑ 5 Changed 4 months ago by cehoyos

Replying to cehoyos:

Why??

What I meant was:
Please either paste your console output into a comment using Code block or attach a text file. Not only is your rtf file needlessly difficult to open, it also contains formatting that makes copying the command line more difficult than needed.

Changed 4 months ago by budman1

text file of command sequence

comment:8 Changed 4 months ago by budman1

I apologize for the rtf. I did not understand what you meant by why and I sometimes forget what I have on my computer, others may not. I have uploaded the text file of all the command sequence.

Note: See TracTickets for help on using tickets.