Search code examples
videoffmpegvideo-capturecodectranscoding

FFmpeg transcoding mpeg2 to H264 and compare frames


I have the following mpeg2 source file:

Stream #0:0[0x900]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x576 [SAR 16:15 DAR 4:3], 4540 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc

And transcoding it to H264 with the following command:

ffmpeg -i source.mpg -vcodec h264_nvenc -r 25 -g 25 -acodec copy -copyts -f mpegts example1.mpg

After this I want to extract identical frames from the both video files:

ffmpeg -y -ss 00:44:16 -i source.mpg -frames:v 1 source.png

ffmpeg -y -ss 00:44:16 -i example1.mpg -frames:v 1 example1.png

But pictures(source.png and example1.png) are different. Please see the source.png: enter image description here

And the example1.png enter image description here

How can I catch the same moment(frame) at the both video?


Solution

  • Instead of time, you can use frame number to extract frames from both videos. For example you can use following to command to get 100th frame from video:-

    ffmpeg -i source.mpg -vf "select=gte(n\,100)" -vframes 1 source.png