FFMPEG sensible defaults

后端 未结 2 606
孤街浪徒
孤街浪徒 2020-12-09 23:48

I\'m using ffmpeg to watermark videos with a PNG file using vfilters like so:

ffmpeg -i 26.wmv -vcodec libx264 -acodec copy -vf \"movie=logo.png [watermark];         


        
相关标签:
2条回答
  • 2020-12-10 00:04

    Here is a set of very good examples http://ffmpeg.org/ffmpeg.html#Examples

    Here is a script i made for converting files to flv video and also adding a preview image

    <?php 
    $filename = "./upload/".$_GET['name'].".".substr(strrchr($_FILES['Filedata']['name'], '.'), 1);
    move_uploaded_file($_FILES['Filedata']['tmp_name'], $filename);
    chmod($filename, 0777);
    exec ("ffmpeg -i ".$filename." -ar 22050 -b 200 -r 12 -f flv -s 500x374 upload/".$_GET['name'].".flv");
    exec ("ffmpeg -i ".$filename." -an -ss 00:00:03 -an -r 1 -s 300x200 -vframes 1 -y -pix_fmt rgb24 upload/".$_GET['name']."%d.jpg");
    ?>
    
    0 讨论(0)
  • 2020-12-10 00:07

    Usually wanting the output to be the "same quality" as the input is an assumed thing that people will always want. Unfortunately, this is not possible when using a lossy encoder, and even lossless encoders may not provide the same quality due to colorspace conversion, chroma subsampling, and other issues. However, you can achieve visually lossless (or nearly so) outputs when using a lossy encoder; meaning that it may look as if the output is the same quality to your eyes, but technically it is not. Also, attempting to use the same bitrate and other parameters as the input will most likely not achieve what you want.

    Example:

    ffmpeg -i input -codec:v libx264 -preset medium -crf 24 -codec:a copy output.mkv
    

    The two option for you to adjust are -crf and -preset. CRF (constant rate factor) is your quality level. A lower value is a higher quality. The preset is a collection of options that will give a particular encoding speed vs compression tradeoff. A slower preset will encode slower, but will achieve higher compression (compression is quality per filesize). The basic usage is:

    1. Use the highest crf value that still gives you the quality you want.
    2. Use the slowest preset you have patience for (see x264 --help for a preset list and ignore the placebo preset as it is a joke).
    3. Use these settings for the rest of your videos.

    Other notes:

    • You do not have to encode the whole video to test quality. You can use the -ss and -t options to select a random section to encode, such as -ss 30 -t 60 which will skip the first 30 seconds and create a 60 second output.

    • In this example the audio is stream copied instead of re-encoded.

    • Remember that every encoder is different, and what works for x264 will not apply to other encoders.

    • Add -pix_fmt yuv420p if the output does not play in dumb players like QuickTime.

    Also see:

    • FFmpeg and x264 Encoding Guide
    • FFmpeg and AAC Encoding Guide
    0 讨论(0)
提交回复
热议问题