[FFmpeg-user] re-encoding extracted image as frame in video
elmismocorreo-avusr at yahoo.com.ar
Sun May 11 21:49:52 CEST 2014
I'm experimenting about video encodings and currently working with h264.
What I'm trying to do is:
1- Extract an i(ntra)-frame from a h264 encoded video as an raw image
2- Change some pixels (distort)
3- Encode the resulting (distorted) image as an i-frame so it can replace the original one (_without_ re-encoding the whole video).
I'm just starting investigating about video encodings and ffmpeg, so I'm a bit lost. What I found so far is the following:
I can extract the first i-frame of a video as a raw image with the following command:
ffmpeg -i Test_Video.mp4 -vf select="eq(pict_type\,I)" -vframes 1 extracted_frame.ppm
With fprobe (I think) I can get more information about the frame:
ffprobe -show_frames -select_streams v Test_Video.mp4
So, if I'm not mistaken, I would need to re-encode the (modified) extracted_frame.ppm as a 91506 bytes packet (pkt_size in fprobe results) and replace that amount of bytes starting at byte 62235 (pkt_pos). But this is what I don't know how to do.
BTW I know that the result of replacing an i-frame without re-encoding the whole video will lead to some ugly pictures (because non-i-frames will be basing their information in the old picture), but that is the point of the test, I want to see the result of different distortions in only one i-frame.
I also (kind of) know that probably the modified i-frame will be repeated in the stream, but I guess that "searching and replacing" all equivalent frames should be as easy as seaching and replacing (checking that what I'm replacing are i-frames).
Last, I'm using the first i-frame for this first test, but I would want to replace any i-frame in the future.
I may be talking nonsenses (as I said, I'm not an expert), any pointer is greatly welcome!
More information about the ffmpeg-user