Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
On 8 October 2016 at 00:31, Carl Eugen Hoyoswrote: > 2016-10-08 0:01 GMT+02:00 Mikhail V : >> BTW after that manipulations a fair question arizes: why >> ffmpeg does not support something like: >> "... -f image2 -i filelist.txt output" > > (This command tries to read a frame / imagefile called filelist.txt) > It does, it is called -f concat and is just an alternative of your > python script. > > Carl Eugen Hi again. Since you say that "-f concat" should work same as -f image2 to create video from images, probably you can pour some light on what I am doing wrong then. Note that ideally I need an MOV file because Sony Vegas cannot open MXF files for some reason so MOV container is preferred. So I have a file "concat.txt" in my case it holds following data: file 'frame0001' file 'frame0003' file 'frame0005' file 'frame0007' file 'frame0009' file 'frame0011' So it is simply a list of odd frames generated by my script. Now to create a MXF I use this command: $ffmpeg -f concat -r 25 -i concat.txt -vcodec copy out.mxf Which is probably not correct? but I don't know exact right command. The result seems correct BUT ffmpeg spits out errors on each frame (here is only last part of the output): [mxf @ 028f2461b200] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 0 Last message repeated 62 times frame= 813 fps= 46 q=-1.0 size= 365042kB time=00:00:00.08 bitrate=37380251.6kbits/s [mxf @ 028f2461b200] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 0 Last message repeated 140 times frame= 954 fps= 52 q=-1.0 size= 428351kB time=00:00:00.08 bitrate=43863093.2kbits/s [mxf @ 028f2461b200] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 0 Last message repeated 138 times frame= 1093 fps= 58 q=-1.0 size= 490762kB time=00:00:00.08 bitrate=50253979.6kbits/s [mxf @ 028f2461b200] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 0 Last message repeated 142 times frame= 1236 fps= 64 q=-1.0 size= 554969kB time=00:00:00.08 bitrate=56828776.4kbits/s [mxf @ 028f2461b200] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 0 Last message repeated 142 times frame= 1379 fps= 70 q=-1.0 size= 619176kB time=00:00:00.08 bitrate=63403573.2kbits/s [mxf @ 028f2461b200] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 0 Last message repeated 120 times frame= 1500 fps= 74 q=-1.0 Lsize= 673506kB time=00:00:00.08 bitrate=68966967.7kbits/s speed=0.00395x video:672000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.224039% As said the resulting file is correct, but what does these errors mean I am not sure. Anyway if I use -f image2 to generate a same video no errors appear - how is that? What is correct command then for concat if I am doing it wrong? Now the same command for mov container. MOV is also valid for DNxHD codec and actually is preferred in my case since MXF files cannot be opened by Sony Vegas. $ffmpeg -f concat -r 25 -i concat.txt -vcodec copy out.mxf And the output (last part of it, since it also spits out errors on each frame): [mov @ 014afd95b200] Non-monotonous DTS in output stream 0:0; previous: 1258, current: 0; changing to 1259. This may result in incorrect timestamps in the output file. [mov @ 014afd95b200] Non-monotonous DTS in output stream 0:0; previous: 1259, current: 512; changing to 1260. This may result in incorrect timestamps in the output file. [mov,mp4,m4a,3gp,3g2,mj2 @ 014aff2a0420] moov atom not found [concat @ 014afd956640] Impossible to open 'out.mov' concat.txt: Invalid data found when processing input frame= 750 fps= 43 q=-1.0 Lsize= 336002kB time=00:00:00.13 bitrate=19882772.1kbits/s speed=0.00788x video:336000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000698% In this case it produces a file but it is _incorrect_ See FFPROBE for mov file - fps is nonsense: $ffprobe out.mov ffprobe version N-79107-g30d1213 Copyright (c) 2007-2016 the FFmpeg developers built with gcc 5.3.0 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
2016-10-08 0:01 GMT+02:00 Mikhail V: > BTW after that manipulations a fair question arizes: why > ffmpeg does not support something like: > "... -f image2 -i filelist.txt output" (This command tries to read a frame / imagefile called filelist.txt) It does, it is called -f concat and is just an alternative of your python script. Carl Eugen ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
> You can do: > $ ffmpeg -i input -vcodec copy -f image2 frame%4d > > Now make symbolic links to every second frame but > with sequential numbers (Don't ask me how). > $ ffmpeg -f image2 -vcodec dnxhd -i linked_frames%4d -vcodec copy out.mxf > (25fps is the default for the image2 demuxer, use -framerate to change it) Great, this worked for me. I don't know symlinks yet however so I have just deleted every second frame with a python script and then ran that command - worked fine, a video file produces correctly. > Or simply concatenate the frames you like with "cat" and do: > $ ffmpeg -i concatenated_file -vcodec copy out.mxf Well with concatenate I am also not very familiar, but I will look in Moritz' solution. I tried to pass a list with only filenames to concat filter but that did not work, seems the list must contain time points as in Moritz' solution to work at all. BTW after that manipulations a fair question arizes: why ffmpeg does not support something like: "... -f image2 -i filelist.txt output" It would ease all those strange manipulations and would not need symlinks or whatever. ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
2016-10-07 14:06 GMT+02:00 Moritz Barsnick: > On Fri, Oct 07, 2016 at 13:07:53 +0200, Carl Eugen Hoyos wrote: >> 2016-10-06 17:34 GMT+02:00 Moritz Barsnick : >> > $ ffmpeg -r 25 -f concat -i concatscript.txt -c:v copy output.mxf >> >> This scales very badly, no? > > It's just a proof of concept. :) It scales nicely (linearly? or is I don't think so or at least I accept it to be magnitudes slower than using the symlinks. > seeking more expensive the deeper you seek?), and works > assuming you have CFR input and output, and you know > those rates, and ... , and ... > ;-) > > It "scales" better then writing every frame to disk and selecting > every second one by symlinking. That's 18 intermediate > files plus 9 symlinks for one hour of video. > Then I'd rather have ffmpeg seek into the input file 9 times. But it actually opens the file 9 times;-( Carl Eugen ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
On Fri, 7 Oct 2016, Moritz Barsnick wrote: On Fri, Oct 07, 2016 at 13:07:53 +0200, Carl Eugen Hoyos wrote: 2016-10-06 17:34 GMT+02:00 Moritz Barsnick: > $ ffmpeg -r 25 -f concat -i concatscript.txt -c:v copy output.mxf This scales very badly, no? It's just a proof of concept. :) It scales nicely (linearly? or is seeking more expensive the deeper you seek?), and works assuming you have CFR input and output, and you know those rates, and ... , and ... ;-) Scaling issues are probably caused by the fact that the concat demuxer reopens the file for each frame, instead of detecting that the next segment is referring to the same file as the previous one. Probably not too hard to improve the concat demuxer to detect such cases and avoid reopening the source. Regards, Marton ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
On Fri, Oct 07, 2016 at 13:07:53 +0200, Carl Eugen Hoyos wrote: > 2016-10-06 17:34 GMT+02:00 Moritz Barsnick: > > $ ffmpeg -r 25 -f concat -i concatscript.txt -c:v copy output.mxf > > This scales very badly, no? It's just a proof of concept. :) It scales nicely (linearly? or is seeking more expensive the deeper you seek?), and works assuming you have CFR input and output, and you know those rates, and ... , and ... ;-) It "scales" better then writing every frame to disk and selecting every second one by symlinking. That's 18 intermediate files plus 9 symlinks for one hour of video. Then I'd rather have ffmpeg seek into the input file 9 times. But both basically suck. I still prefer that "select" bitstream filter. ;-) Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
2016-10-06 17:34 GMT+02:00 Moritz Barsnick: > $ ffmpeg -r 25 -f concat -i concatscript.txt -c:v copy output.mxf This scales very badly, no? Carl Eugen ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
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 ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
2016-10-06 16:16 GMT+02:00 Mikhail V: > I admit I am not fully getting your idea then. Your original email (and subsequent ones) sounded as if you knew exactly what has to be done, you were just asking if it is possible without a little shell magic (I think it is not). You can do: $ ffmpeg -i input -vcodec copy -f image2 frame%4d Now make symbolic links to every second frame but with sequential numbers (Don't ask me how). $ ffmpeg -f image2 -vcodec dnxhd -i linked_frames%4d -vcodec copy out.mxf (25fps is the default for the image2 demuxer, use -framerate to change it) Or simply concatenate the frames you like with "cat" and do: $ ffmpeg -i concatenated_file -vcodec copy out.mxf Carl Eugen ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
2016-10-06 15:53 GMT+02:00 Marcelo Boufleur: > I'm not sure that what Mikhail wants really exists. If I understand > correctly, you want to retain original encoding and drop one frame every > two frames. > > If this would be possible, you would have to work at the DNxHD inner level, > identify each frame start/end (by headers), bit-stream copy whichever > frames you would need, Fortunately, FFmpeg does all this for you: We call it "parsing" and it is necessary for many (general) use-cases. > and then re-generate the DNxHD layer and headers to > reflect all the changes you have made. No such header exists for dnxhd, just for mxf. Carl Eugen ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
On 6 October 2016 at 10:07, Carl Eugen Hoyoswrote: > 2016-10-05 23:08 GMT+02:00 Mikhail V : >> On 5 October 2016 at 19:55, Carl Eugen Hoyos wrote: >>> 2016-10-05 15:45 GMT+02:00 Mikhail V : >>> Is it possible that ffmpeg cannot do this without re-encoding? >>> >>> You can export single frames and delete half of them using a >>> shell script. > >> Sure I can :) Also I can just directly recode it in 25 fps in any codec. >> So I suppose the answer is - I can't do it without re-encode. > > If you want to drop every second frame without re-encoding at > all, you can export all frames as single frames and use a shell > script to drop half of them. I admit I am not fully getting your idea then. I want the output as same video file. If I export as images then it is just a folder with images. Yes they will be not changed, but if I want them back in a DNxHD video file, how can I guarantee that the information will be not changed due to compression? Do you mean this is possible somehow to put the images back in video file without touching the image information? ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
On Thu, Oct 06, 2016 at 10:53:14 -0300, Marcelo Boufleur wrote: > I'm not sure that what Mikhail wants really exists. If I understand > correctly, you want to retain original encoding and drop one frame every > two frames. I understand the same thing. (Carl Eugen was concentrating on Mikhail's "not re-encoding" wording, which can of course be achieved by just decoding. ;-)) Keep every second frames without decoding them, but re-assembling them to a valid MXF. > If this would be possible, you would have to work at the DNxHD inner level, > identify each frame start/end (by headers), bit-stream copy whichever > frames you would need, and then re-generate the DNxHD layer and headers to > reflect all the changes you have made. Exactly. Since you don't want to decode (which implies re-encoding), this would be with "-c:v copy" and would effectively be a bitstream filter. I'm not aware that any such filter exists (and whether the ffmpeg devs would even consider accepting integrating such a bsf). It pure theory, this *could* even be done for more codecs than just DNxHD. > I may be wrong, but I believe with current FFmpeg implementation you can > only work either with stream copy (if you don't want to change encoding, > nor frame rate, which defies his purpose), or use the previous suggestions > to cut framerate by half, which implies on re-encoding (which again, defies > his purpose). 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. :) Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
I'm not sure that what Mikhail wants really exists. If I understand correctly, you want to retain original encoding and drop one frame every two frames. If this would be possible, you would have to work at the DNxHD inner level, identify each frame start/end (by headers), bit-stream copy whichever frames you would need, and then re-generate the DNxHD layer and headers to reflect all the changes you have made. I may be wrong, but I believe with current FFmpeg implementation you can only work either with stream copy (if you don't want to change encoding, nor frame rate, which defies his purpose), or use the previous suggestions to cut framerate by half, which implies on re-encoding (which again, defies his purpose). ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
2016-10-05 23:08 GMT+02:00 Mikhail V: > On 5 October 2016 at 19:55, Carl Eugen Hoyos wrote: >> 2016-10-05 15:45 GMT+02:00 Mikhail V : >> >>> Is it possible that ffmpeg cannot do this without re-encoding? >> >> You can export single frames and delete half of them using a >> shell script. > Sure I can :) Also I can just directly recode it in 25 fps in any codec. > So I suppose the answer is - I can't do it without re-encode. If you want to drop every second frame without re-encoding at all, you can export all frames as single frames and use a shell script to drop half of them. Carl Eugen ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
On Wed, 5 Oct 2016, Mikhail V wrote: On 5 October 2016 at 19:55, Carl Eugen Hoyoswrote: 2016-10-05 15:45 GMT+02:00 Mikhail V : Is it possible that ffmpeg cannot do this without re-encoding? You can export single frames and delete half of them using a shell script. Carl Eugen Sure I can :) Also I can just directly recode it in 25 fps in any codec. So I suppose the answer is - I can't do it without re-encode. I was just wondering why there is no such function for intraframe codecs, would be very handy in my opinion. You may try generating an ffconcat file which seeks to every second frame, then force the halved frame rate for it, finally mux this with the original audio using streamcopy. With a little luck, this should work. Regards, Marton ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
On 5 October 2016 at 19:55, Carl Eugen Hoyoswrote: > 2016-10-05 15:45 GMT+02:00 Mikhail V : > >> Is it possible that ffmpeg cannot do this without re-encoding? > > You can export single frames and delete half of them using a > shell script. > > Carl Eugen Sure I can :) Also I can just directly recode it in 25 fps in any codec. So I suppose the answer is - I can't do it without re-encode. I was just wondering why there is no such function for intraframe codecs, would be very handy in my opinion. ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
On 5 October 2016 at 18:06, Erik Dobberkauwrote: >> Hello, >> >> I have a camera recording which is an MXF file and the codec is DNxHD >> I suppose it is a single-frame codec so literally it is a container of >> images which are independently stored in the file. >> Recordings are taken at 50 fps progressive. > > > Hi Michail, > > this is a TV standard, 720p50. Nothing exotic. > > >> Now what I want is to extract only half of the frames, so that it becomes >> 25 fps > > > Why would you want to do that? > You're getting standard-incompliant video. In other words: This is wrong. You are right, but what is standard depend on situation, currently the only working mode for me is 25 progressive. I know 50 fps would be better of course, but it does not depend on me but the prescriptions from the broadcaster. ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
2016-10-05 15:45 GMT+02:00 Mikhail V: > Is it possible that ffmpeg cannot do this without re-encoding? You can export single frames and delete half of them using a shell script. Carl Eugen ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Selecting/dropping frames without re-encoding
> Hello, > > I have a camera recording which is an MXF file and the codec is DNxHD > I suppose it is a single-frame codec so literally it is a container of > images which are independently stored in the file. > Recordings are taken at 50 fps progressive. Hi Michail, this is a TV standard, 720p50. Nothing exotic. > Now what I want is to extract only half of the frames, so that it becomes > 25 fps Why would you want to do that? You're getting standard-incompliant video. In other words: This is wrong. > Note that I need to do it _without re-encoding_ for two reasons: > 1. Conversion must be as fast as possible, files can be really huge > 2. No changes to original information should occur > > Theoretically this is an elementary operation, it should just take > every second frame from source and write to output > leaving everything else as is. > I have tried several options whith "-r ..." and added "-c:v copy" > These commands I have tried: > > ffmpeg -i Capture0006V_720p.mxf -r 25 -c:v copy out1.mxf > ffmpeg -r 50 -i Capture0006V_720p.mxf -r 25 -c:v copy out1.mxf > ffmpeg -r 2 -i Capture0006V_720p.mxf -r 1 -c:v copy out1.mxf > > But they all produce again 50 fps video, so I suppose stream copy just > ignores all "-r" options so I don't know what can I do to achieve > what I want. I have searched a lot, so I've registered here > hoping for solution. > > Is it possible that ffmpeg cannot do this without re-encoding? > If no, how can one do this? > Thanks in advance. > Stream Copy does that... it copies streams. Dropping every second frame will destroy motion smoothness thus ruin your video. But you can do that with another filter. Erik ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".