[FFmpeg-user] Selecting/dropping frames without re-encoding

Moritz Barsnick barsnick at gmx.net
Thu Oct 6 18:34:21 EEST 2016


On Thu, Oct 06, 2016 at 16:07:02 +0200, Moritz Barsnick wrote:
> I found the suggestion to use the concat demuxer with streamcopy very
> interesting. Assuming it can seek and cut precisely, that could work -
> again in theory. Let's experiment with that. :)

So, where are your results, everyone? ;-) Here are mine.

I created a 50 fps DNxHR MXF file. The testsrc2 filter/source kindly
puts the frame numbers onto each frame:

$ ffmpeg -f lavfi -i testsrc2=s=hd720:r=50 -c:v dnxhd -profile:v dnxhr_hq -t 3 input.mxf

I created a concat script for these three seconds, to select every
second frame, which means stepping forward by 0.040 (two frames at 50
fps), for a duration of 0.020 (one frame):

$ perl -e 'print "ffconcat version 1.0\n\n"; my $t = 0; while ($t <= 3) { printf("file input.mxf\ninpoint %1.3f\nduration 0.020\noutpoint %1.3f\n\n", $t, $t + 0.020); $t += 0.040; }' > concatscript.txt

Then I used this concat demuxer script to do the actual extraction:

$ ffmpeg -r 25 -f concat -i concatscript.txt -c:v copy output.mxf

Visual inspection of the result shows me that every second frame was
extracted, at a resulting frame rate of 25 fps.

Verifying with the frashhash demuxer showed me that every second frame
is indeed identical:

$ ffmpeg -i input.mxf -c copy -f framehash input.mxf.hash
$ ffmpeg -i output.mxf -c copy -f framehash output.mxf.hash

Bingo! :-)

Still, a bitstream filter would be nifty. ;-)

Moritz


More information about the ffmpeg-user mailing list