| 70 | | == Alternative Encoding Options == |
| 71 | | |
| 72 | | !YouTube provides a guide to [https://support.google.com/youtube/answer/1722171?hl=en Advanced encoding settings] which, if certain recommendations are followed, will produce a video that will not be recoded after it is uploaded. (To verify that this works on !YouTube, download your posted video with a streaming media capture utility such as Orbit Downloader or the DownloadHelper add-on for Firefox, and then compare it to your original video. Using the download link in !YouTube's control panel produces a recoded video that is not what you uploaded.) More than likely, some of the recommendations have to do with Adobe's Flash player, so these may also work for other video sharing sites. |
| 73 | | |
| 74 | | The crucial options appear to be the container format (MP4) and options, the video and audio codecs, and the right profile for each codec (but with additional restrictions on the video stream). Video frame rates, resolutions, and aspect ratios, audio sample rates, and bit rates for video and audio are not crucial, so long as the video and audio codecs will encode them. !YouTube, at least, supports VBR video and audio and, with the latest Flash Player versions, Variable Frame Rate video. |
| 75 | | |
| 76 | | Note: all the following options to FFMPEG control the output file that will be uploaded. They must all ''follow'' the list of input sources on the command line. |
| 77 | | |
| 78 | | * MP4 container format |
| 79 | | * MOOV atom at the front of the file (Fast Start) |
| 80 | | * FFMPEG option: ''-movflags faststart'' |
| 81 | | |
| 82 | | * Audio: AAC |
| 83 | | * Profile: Low Complexity (LC) |
| 84 | | * [[AAC|FFmpeg and AAC Encoding Guide]] |
| 85 | | |
| 86 | | * Video: H.264 AVC (FFMPEG option: ''-c:v libx264'') |
| 87 | | * Progressive scan (not interlaced) |
| 88 | | * Detect interlaced video (including field order) |
| 89 | | * [http://mediaarea.net/en/MediaInfo MediaInfo] |
| 90 | | - FFMPEG's [https://ffmpeg.org/ffmpeg-filters.html#idet idet] filter (adjust ''-ss'' and ''-frames:v'' to taste): |
| 91 | | {{{ |
| 92 | | ffmpeg -y -ss 00:03:00 -i INPUT -an -frames:v 200 -vf idet -f rawvideo /dev/null #or NUL for Windows |
| 93 | | }}} |
| 94 | | ''idet'' will output stats to your console just before FFMPEG exits. |
| 95 | | * FFMPEG de-interlacing options: |
| 96 | | * [https://ffmpeg.org/ffmpeg-filters.html#fieldmatch fieldmatch] filter to [http://en.wikipedia.org/wiki/Telecine#Reverse_telecine_.28a.k.a._inverse_telecine_.28IVTC.29.2C_reverse_pulldown.29 inverse telecine] |
| 97 | | * [https://ffmpeg.org/ffmpeg-filters.html#yadif-1 yadif] filter to de-interlace |
| 98 | | * [[FilteringGuide|FFMPEG Filtering Guide]] |
| 99 | | * Profile: High |
| 100 | | - FFMPEG option: ''-preset veryfast''[[BR]]''libx264'' will automatically set the profile to ''High.'' Selecting a preset faster than ''veryfast'' is not recommended. |
| 101 | | * Consecutive B-frames: 2 |
| 102 | | * Consecutive B-frames must be limited to 2, regardless of other ''libx264'' options. |
| 103 | | * FFMPEG option: ''-bf 2'' |
| 104 | | * Closed GOP, approximately half the video frame rate |
| 105 | | * The default, 12, works for 24-25 fps. For NTSC and 30 fps, select 15. |
| 106 | | * FFMPEG option: ''-g'' |
| 107 | | * Chroma subsampling: 4:2:0 |
| 108 | | * Translation: yuv420p |
| 109 | | * Check input file pixel format: |
| 110 | | {{{ |
| 111 | | ffprobe -select_streams v -show_streams InputFile |
| 112 | | }}} |
| 113 | | * FFMPEG option: ''-pix_fmt yuv420p'' |
| 114 | | |
| 115 | | Some examples: |
| 116 | | |
| 117 | | Inverse telecine a NTSC DVD rip (output video framerate will be "ntsc-film", 24000/1001): |
| 118 | | {{{ |
| 119 | | ffmpeg -i input.mpg -strict experimental -c:a aac -b:a 128k -vf "fieldmatch=combmatch=full:mode=pc_n_ub, yadif=deint=interlaced, decimate" -pix_fmt yuv420p -c:v libx264 -crf 18 -preset slow -tune film -bf 2 -movflags faststart -shortest output.mp4 |
| 120 | | }}} |
| 121 | | |
| 122 | | Same thing, but just de-interlace it (output video framerate will be "ntsc", 30000/1001): |
| 123 | | {{{ |
| 124 | | ffmpeg -i input.mpg -strict experimental -c:a aac -b:a 128k -vf yadif -pix_fmt yuv420p -c:v libx264 -crf 18 -preset slow -tune film -g 15 -bf 2 -movflags faststart -shortest output.mp4 |
| 125 | | }}} |
| 126 | | |