VideoHelp Forum




+ Reply to Thread
Results 1 to 24 of 24
  1. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    Hi
    It's a movie with redundant frames. Let's concentrate on a part of it I uploaded:
    https://drive.google.com/file/d/1ndHrGElxIDaM4MWAK98UvauziSr2f68N/view?usp=sharing
    The sample got from the movie contains 32 frames. When I open the video in Avidemux, I see that only these frames differ with their previous frames (I specify them with * and specify all frames types (I, B or P)):

    No. type time
    ----- ----- -----
    *0 I 020 (It's evident that the first frame which is a key frame should contain data)
    1 B 030
    2 B 040
    3 P 050
    *4 B 060
    5 B 070
    6 B 080
    7 P 090
    *8 B 100
    *9 B 110
    10 B 120
    *11 B 130
    *12 P 140
    13 B 150
    14 B 160
    15 P 170
    *16 B 180
    *17 B 190
    *18 B 200
    *19 B 210
    *20 P 220
    21 B 230
    22 B 240
    23 P 250
    *24 B 260
    25 B 270
    26 B 280
    27 P 290
    *28 B 300
    *29 B 310
    30 B 320
    31 P 330

    My question is:
    Why the other frames are there in the movie while they don't contain any move? I wrote a C program on Ubuntu to use libavxxx and found that all frames have data. When a frame causes no change in its previous image, why should it exist? I feel that something is wrong with the movie and the whole size may be decreased if the redundant frames may get out of the movie. Don't you think so? If you think I'm correct, how can I correct the movie?
    Thanks
    Quote Quote  
  2. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    I include the output of the program which dumps the content of each frame separately:
    https://pastebin.com/ZqnmppD4
    You see that all have data while most don't cause change in image.
    Quote Quote  
  3. Why upload a uselessly short sample? Please make available 10 seconds or so.
    Quote Quote  
  4. First of all, there are duplicate frames because a video of a lower frame rate was converted to a constant 100 fps. Secondly, there are more duplicates than you think. There are really only 7 unique frames out of the 32. Which makes the underlying frame rate about 23 fps. As manono suggested, a longer sample would be good. And include a medium speed panning shot to make analysis easier.
    Quote Quote  
  5. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    Why not? I thought the sample might be enough and if I didn't upload the whole movie it was because of volume as well as copyright issues.
    Here:
    https://drive.google.com/file/d/1Ryaa1FJ7yxiJkiV1ABNMBXScMhHbDQdN/view?usp=sharing
    Quote Quote  
  6. It was originally 25p. Someone converted to 100p by duplicating frames. Attached is 9 seconds decimated to 25p.

    Code:
    LWLibavVideoSource("boys will be boys_2.mp4", cache=false, prefer_hw=2) 
    SelectEvery(4) # discard 3 of every 4 frames, converting 100p to 25p
    Trim(18100, 18341) # select a panning shot (easy to check for smoothness)
    Image Attached Files
    Last edited by jagabo; 20th Apr 2021 at 19:32.
    Quote Quote  
  7. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    Thank you. How did you find that it has been originally a 25 fps video? And how can I convert the whole movie to a proper fps? (I prefer ffmpeg).
    The video is once converted from H264 to H265 by me and I doubt that has been my mistake in changing frame rate. I used something like:
    Code:
    ffmpeg -i <file1> -c:v libx265 -map 0 <file2>
    It should not has changed the frame rate. Maybe the original video had been converted improperly?
    Quote Quote  
  8. Originally Posted by hamidi2 View Post
    Thank you. How did you find that it has been originally a 25 fps video?
    Stepping through the video frame by frame you can see four identical frames in a row. Like AAAABBBBCCCCDDDD... 100/4 = 25.

    Originally Posted by hamidi2 View Post
    The video is once converted from H264 to H265 by me and I doubt that has been my mistake in changing frame rate. I used something like:
    Code:
    ffmpeg -i <file1> -c:v libx265 -map 0 <file2>
    It should not has changed the frame rate. Maybe the original video had been converted improperly?
    Obviously, that command line should not have changed the frame rate from 25p to 100p.

    Originally Posted by hamidi2 View Post
    And how can I convert the whole movie to a proper fps? (I prefer ffmpeg).
    ffmpeg has a decimate filter:

    Code:
    ffmpeg -i 100p.mp4 -vf decimate=2,decimate=2 25p.mp4
    I don't know if there's an equivalent to AviSynth's SelectEvery() filter.
    Quote Quote  
  9. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    I got the proper answer I was looking for, thanks.
    I mostly use ffmpeg. So it's not a problem if you don't know its equivalent filter to AviSynth. I think it's a more professional tool.
    Just let me know what's the decimate filter. Could I use decimate=4 instead? What does it do and why did you use it two times?
    Quote Quote  
  10. Originally Posted by hamidi2 View Post
    Could I use decimate=4 instead? What does it do and why did you use it two times?
    No, you can't use decimate=4. The decimate filter in ffmpeg removes 1 in N frames. So decimate=4 removes 1 of every 4 frames reducing the frame rate from 100 to 75 fps. I used decimate=2 to reduce the frame rate to 50 fps then again to further reduce it to 25 fps.

    The decimate filter in AviSynth can remove M in N frames. So you can go directly from 100 fps to 25 fps with Decimate(Cycle=4, CycleR=3) (remove 3 of every 4 frames).
    Quote Quote  
  11. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    Oh okay,
    Can it detect I-frames so that no re-encoding will be required? I don't want to re-encode and cause downgrading quality.
    Quote Quote  
  12. Originally Posted by hamidi2 View Post
    Oh okay,
    Can it detect I-frames so that no re-encoding will be required?
    No. It has to be reencoded. The I-frames will be spread out over many more frames than 4. It wouldn't help you anyway.
    Quote Quote  
  13. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    Okay, thanks
    Quote Quote  
  14. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    I converted the video as you guided. The frame rate got corrected and the redundant frames got disappeared. But it's weird that no reasonable change in size occurred. The 264.3 MB file got 250.9 MB in size. Usually if I re-encode a video without changing frame rate such a change in volume takes place. So, I can deduce that the redundant frames in the original video didn't occupy such a reasonable volume of the file. I would expect the file size to reduce to about half or less!
    Quote Quote  
  15. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Originally Posted by hamidi2 View Post
    I converted the video as you guided. The frame rate got corrected and the redundant frames got disappeared. But it's weird that no reasonable change in size occurred. The 264.3 MB file got 250.9 MB in size. Usually if I re-encode a video without changing frame rate such a change in volume takes place. So, I can deduce that the redundant frames in the original video didn't occupy such a reasonable volume of the file. I would expect the file size to reduce to about half or less!
    Did you choose the same bitrate as the original file?
    Quote Quote  
  16. Code:
    stream size = bitrate * running time
    So if you used the same bitrate you would get the same file size, regardless of the frame rate. Even if you use CRF encoding, duplicate frames require hardly any bitrate (which I think you saw in your earlier analysis). So a 100 fps video with dups would only be a little bigger than the 25 fps video without dups. Also, x264 is frame rate aware. When CRF encoding it will use higher quantizers (lower quality) at higher frame rates -- on the theory that small defects seen for 1/100 second will be less visible than a similar defects at see for 1/25 second.
    Quote Quote  
  17. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    @davexnet: I didn't specify bitrate change for ffmpeg. So if it's changed, it has been its own decision. The original video's bitrate is 282kbps and the converted one's bitrate is 269kbps.
    @jagabo: Your text is higher level than my knowledge I think a newbie like me can't understand it completely, but I try my best. It's a good formula I didn't know about. It shows that any stream size depends only on bitrate as well as its running time, not frame rate. It concludes that a 1000fps video is the same in size as its 1fps equivalent in runtime. It's weird. How can it be possible? So where do these additional data go? I saw in the program I wrote that even these duplicate and redundant frames have size and so they need additional bitrate.
    I don't know any about CRF encoding. What is it?
    I also don't know what you mean by frame rate awareness. The same for 'defects'. Sorry, I'm really a newbie in such matters.
    Quote Quote  
  18. The definition of bitrate is:

    Code:
    bitrate = stream size / running time
    So by simple algebraic manipulation you get the version of the equation I gave earlier:

    Code:
    stream size = bitrate * running time
    In the command line you gave earlier:

    Code:
    ffmpeg -i <file1> -c:v libx265 -map 0 <file2>
    you are using crf encoding (the default for x265 if you don't specify otherwise). It's basically a constant quality encoding method. You specify the quality you want and the encoder uses whatever bitrate is needed to deliver that quality. You didn't specify a crf value so the default value of 28 was used. Lower crf values give higher quality, higher crf values give lower quality. Think of the crf as the amount of detail that's discarded. The more detail you discard the smaller the file will be.
    Quote Quote  
  19. I don't know if there's an equivalent to AviSynth's SelectEvery() filter.
    iirc. shuffleframes should work, as an ffmpeg alternative to SelectEvery() in Avisynth,..
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  20. Thanks for the input. I tried shuffleframes but I couldn't get it to remove frames, only reorder frames or replace frames with copies of others. The docs say using -1 deletes that frame but "shuffleframes=0 -1 -1 -1" gives four copies of frame 0. Frames 1, 2, and 3 were replaced with copies of frame 0, not removed. Am I missing something?
    Quote Quote  
  21. A quick test with:
    Code:
    ffplay -i "f:\TestClips&Co\files\5000frames.mp4" -vf shuffleframes="0 -1 -1 -1"
    (5000frames.mp4 is a simple clip with numbered frames)
    returns frames 0, 4, 8, 12, ... which is what I would have expected,..
    (split source in packages of 4, keep the first frame drop the rest)
    -> what does your call look like exactly? (missing quotes?)
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  22. -vf shuffleframes does not automatically adjust the timestamps

    everything in ffmpeg runs on timestamps, and most filters do not auto adjust like avisynth filters (e.g. if you use selecteven or similar, the fps and their timestamps will automatically be cut in half)

    so you'd have to follow up with something like -vf fps for this situation where you have 100fps, keeping 1 of 4

    5min test
    Code:
    ffmpeg -i "boys will be boys_2.mp4" -vf "shuffleframes='0 -1 -1 -1', fps=25" -c:v libx264 -crf 20 -c:a copy -t 00:05:00 out.mp4 -y
    Quote Quote  
  23. Good to know, I normally use "-r 25" when using ffmpeg for encoding (I usually only use it for decoding and set the fps in the encoder )
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  24. Originally Posted by poisondeathray View Post
    -vf shuffleframes does not automatically adjust the timestamps

    everything in ffmpeg runs on timestamps, and most filters do not auto adjust like avisynth filters (e.g. if you use selecteven or similar, the fps and their timestamps will automatically be cut in half)

    so you'd have to follow up with something like -vf fps for this situation where you have 100fps, keeping 1 of 4

    5min test
    Code:
    ffmpeg -i "boys will be boys_2.mp4" -vf "shuffleframes='0 -1 -1 -1', fps=25" -c:v libx264 -crf 20 -c:a copy -t 00:05:00 out.mp4 -y
    Jeez, I didn't realize fps was a video filter as well as a property. In that case you just use "-vf fps=25" to get simple decimation.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!