Newest 'libx264' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/libx264

Les articles publiés sur le site

  • When compressing a set of images with libx264, why does frame rate affect final output size ?

    3 avril 2018, par jd20

    I'm using ffmpeg to encode a set of images as a short timelapse video, using libx264 codec. My first attempt, I encoded it at 30 FPS, using:

    ffmpeg -r 30 -pattern_type glob -i "*.jpg" -vcodec libx264 -crf 30 -pix_fmt yuv420p output.mp4
    

    With 60 frames, that gives me a 163 KB file that's 2 seconds long. Then I realized I needed it to be slower, so I re-ran the same command, but changed -r to 2. Now I have a file that's 30 seconds long, but the size jumped to 891 KB! The video quality looks perceptually the same.

    How do I encode at a slower frame rate, without the final file size ballooning?


    Notes: Some theories I had, and things I checked. First, to make sure ffmpeg wasn't duplicating frames in the longer verison, I check the I/P/B counts. The 30 FPS file had:

    [libx264 @ 0x7f9b26001c00] frame I:1     Avg QP:30.67  size: 44649
    [libx264 @ 0x7f9b26001c00] frame P:15    Avg QP:31.19  size:  5471
    [libx264 @ 0x7f9b26001c00] frame B:44    Avg QP:31.45  size:   767
    

    The 2 FPS file had:

    [libx264 @ 0x7fcd32842200] frame I:1     Avg QP:21.29  size: 90138
    [libx264 @ 0x7fcd32842200] frame P:15    Avg QP:22.48  size: 33686
    [libx264 @ 0x7fcd32842200] frame B:44    Avg QP:26.29  size:  6674
    

    So, the I/P/B counts are identical, but the QP is much lower for the 2 FPS file. To offset, I tried increasing -crf for the 2 FPS file, to get about the same target size, but that just gave me a very blurry video (had to go to crf=40). I tried messing with -minrate, -maxrate, -bt, none helped. I'm guessing there is some x264 codec setting which is frame rate dependent, but I'm at a loss trying to figure out which one (from what I understand, constant bitrate is affected by frame rate but CRF should not be, but maybe I'm misunderstanding it.

  • ffmpeg settings for high quality youtube videos [migrated]

    1er avril 2018, par pb.

    I am trying to record short video of my desktop and upload it to youtube. The problem is that every time when I upload it to youtube or even dropbox (as video), the quality is much worse.

    My ffmpeg execution:

    ffmpeg -f x11grab -s 1366x768 -r 30 -i :0.0 -codec:v libx264 -crf 10 -bf 20 -flags +cgop -pix_fmt yuv440p -movflags faststart help.mp4
    

    based on:

    ffmpeg -i  -codec:v libx264 -crf 21 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart .mp4
    

    which I found here

    Original file (.zip): https://www.dropbox.com/s/xlkr83rkqfxon23/help.mp4.zip?dl=0

    File after upload to youtube: https://www.youtube.com/watch?v=ewEUgpXOpmg

    As you can see, I loss quality after upload to youtube.

    Could you help me?
    How should I choose the appropriate parameters to record and upload high quality video?

  • Documentations and tutorials for libx264 ?

    28 mars 2018, par David Tree

    I've compiled X264 source code and got libx264.so and x264.h. Surprisingly, I could not find any lib documentation (VideoLan/wiki) except for the header file (x264.h) when I was trying to write a simple program using lib APIs. There are some sample codes on Internet but I do want to know what the lib exactly can do.

    I'm a rookie. Does anyone know if there are good documentations or tutorials for x264?

  • desktop recording - ffmpeg settings for high quality youtube videos

    21 mars 2018, par pb.

    I am trying to record short video of my desktop and upload it to youtube. The problem is that every time when I upload it to youtube or even dropbox (as video), the quality is much worse.

    My ffmpeg execution:

    ffmpeg -f x11grab -s 1366x768 -r 30 -i :0.0 -codec:v libx264 -crf 10 -bf 20 -flags +cgop -pix_fmt yuv440p -movflags faststart help.mp4
    

    based on:

    ffmpeg -i  -codec:v libx264 -crf 21 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart .mp4
    

    which I found here

    Original file (.zip): https://www.dropbox.com/s/xlkr83rkqfxon23/help.mp4.zip?dl=0

    File after upload to youtube: https://www.youtube.com/watch?v=ewEUgpXOpmg

    As you can see, I loss quality after upload to youtube.

    Could you help me?
    How should I choose the appropriate parameters to record and upload high quality video?

  • Encoding for fastest decoding with ffmpeg

    20 mars 2018, par nbubis

    Encoding with ffmpeg and libx264, are there presets or flags that will optimize decoding speed?

    Right now it seems that videos transcoded with similar file sizes are decoded at very different speeds using Qtkit, and I was wondering whether there are options for encoding such that the decoding speed will be maximal.