[FFmpeg-user] Cut-edits with ffmpeg

Paul B Mahol onemda at gmail.com
Thu Jul 25 22:30:04 CEST 2013


On 7/25/13, thljcl <jiachielee at live.com> wrote:
> Let’s see if I get your question correctly. You have a video with
> uncompressed file format. You want to
>
> edit some frames; but even if you found the exact frame number, ffmpeg might
> not be able to extract the
>
> frame you want. Assuming that I understood your question correctly, here is
> what I would do if I were
>
> you or in similar situation.
>
> Assume that your video is of constant frame rate, frame number will then be
> directly proportional to the
>
> time. I’m not really sure which video codec is being used to store video
> information. I would assume
>
> that you might be in favor of lossless compression compared with lossy
> compression, especially when you
>
> still need to edit the videos. You can transcode the video to H.264 lossless
> if it is not already in
>
> H.264 lossless.
>
> ffmpeg -i "input.avi" -vcodec "libx264" -crf "0" "input.mkv"
>
> You can convert the entire video into a series of image sequence but they
> may end up costing a lot of
>
> storage space. More efficiently, you can just get a small part of video
> which contains the frames you
>
> want to edit. You can do that with mkvtoolnix. It split, merge, remove
> tracks, and add tracks to MKV
>
> file, without re-encoding the video/audio/subtitle; but when it comes to
> accuracy of splitting video
>
> files based on duration or time, there will be discrepancies due to
> limitation of accuracy. While it
>
> cannot split the frame you want exactly, it can split video to a small part,
> which you can later convert
>
> that small part to a series of images sequence, instead of entire videos.
>
> mkdir “frames”
> ffmpeg -i "input.mkv" "frames\f_%%1d.png"
>
> After you edited the frames you want,
>
> ffmpeg -r "24" -i "frames\f_%%1d.png" -vcodec "libx264" -crf "0"
> "output-1.mkv"
>
> Here I assume that the frame rate of your video is 24 FPS.
>
> You can then join the video back using mkvtoolnix.
>
> If your video source is of variable frame rate, you need to how the frame
> rate changes over time in
>
> order to preserve the original frame rate. The only way to know exactly is
> that you actually specify how
>
> the frame rate changes yourself. If you do know how the frame rate changes,
> To convert the video part to image sequence without changing frame rate,
>
> mkdir "frames"
> ffmpeg -r "1" "input.mkv" "frames\f_%%1d.png"
>
> To change it back to videos, you need to do it part by part, which means
> that each part is of constant
>
> frame rate; when they are joined together, its frame rate is of course
> variable.
> If you do not know how the frame rate changes but do know that frame rate is
> variable due to the setting
>
> of recording device or other reasons, you do not want to change the playback
> speed, you need to change
>
> the frame rate to a constant frame rate you find suitable, for example,
>
> ffmpeg -i "input.avi" -vf "fps=24" -vcodec "libx264" -crf "0" "input.mkv"
>
> Using video filter to change frame rate will of course result in the drop or
> add of frames to achieve
>
> the constant frame rate you designated. Personally, I generally use 24 FPS,
> the industry standard
>
> adopted by film industry.

That last line says everything.....


More information about the ffmpeg-user mailing list