Topic: Mp4 conversion issues / quality degradation

Posted under General

So I've been uploading a bunch from furaffintiy over to e621, but the artist uploads to furaffintiy in an mp4 format which e621 doesn't accept. I convert the MP4s into AV1 format using this website ( https://convertio.co/mp4-av1 ). It seems to work, but staff have noted that there seems to be some fort of degradation happening in the conversion process. so when I upload the video, the staff have been kind enough to replace the posts with a version with better quality. Though the issue here is, as they are being replaced, my upload limit is slowly going down. I'm now at a limit of 9 and I do not wish to have that go any lower, considering I have over 100 more animations to post. I would very much appreciate it if someone could provide me with a way to convert these MP4 videos to an AV1 format without any issues resulting in a post replacement.

donovan_dmc said:
I reiterate again, people never listen

Mairo mentioned handbrake in your original topic, either look up how to use ffmpeg or figure out how that thing works

I wish I knew enough of this tech speak to be able to listen properly.

donovan_dmc said:
I reiterate again, people never listen

Mairo mentioned handbrake in your original topic, either look up how to use ffmpeg or figure out how that thing works

I got it, now I just gotta learn how to make it work.

donovan_dmc said:
I reiterate again, people never listen

Mairo mentioned handbrake in your original topic, either look up how to use ffmpeg or figure out how that thing works

Alright, so what are the specifics of AV1 format which is better for e621? AV1 (SVT) or AV1 10-bit (SVT)? Having the specifications of which file types/encoding things work best for e621 would help. I wish e621 had a little guide on how to get the best conversions of videos to use on the website.

Mairo

Janitor

freakazoid123 said:
I wish I knew enough of this tech speak to be able to listen properly.

I got it, now I just gotta learn how to make it work.

https://trac.ffmpeg.org/wiki/Encode/AV1
ffmpeg -i input.mp4 -metadata title="CHANGE THIS TITLE" -metadata comment="CHANGE THIS SOURCE URL" -c:v libsvtav1 -preset 0 -svtav1-params tune=0 -g 150 -pix_fmt yuv420p -crf 14 -an -movflags +faststart output.mp4
On Handbrake, enable "web optimized", disable all resolution limits and anamorphic, all filters off, encoder SVT, FPS same as source and constant, preset to 0, quality to 14 RF, audio either disable if there's none, passthrough if it's AAC or convert to 160k opus if you have no idea, disable subtitles and chapters and I guess that's all.

freakazoid123 said:
Alright, so what are the specifics of AV1 format which is better for e621? AV1 (SVT) or AV1 10-bit (SVT)? Having the specifications of which file types/encoding things work best for e621 would help. I wish e621 had a little guide on how to get the best conversions of videos to use on the website.

e621:supported_filetypes "..Should be YUV420 8bit.."
Ideally artists themselves would do this from their own software to begin with, but constant quality mode with slow encoding settings should be enough.

howto:transcode and convert if I had any extra time to do shit, already just moved howto:sites and sources away from my profile and others took over it.
Doesn't help that there's so many variables and then software also updates, apparently SVT only had three pass, now has two pass mode, but it's still not exposed to FFmpeg so????

mairo said:
https://trac.ffmpeg.org/wiki/Encode/AV1
ffmpeg -i input.mp4 -metadata title="CHANGE THIS TITLE" -metadata comment="CHANGE THIS SOURCE URL" -c:v libsvtav1 -preset 0 -svtav1-params tune=0 -g 150 -pix_fmt yuv420p -crf 14 -an -movflags +faststart output.mp4
On Handbrake, enable "web optimized", disable all resolution limits and anamorphic, all filters off, encoder SVT, FPS same as source and constant, preset to 0, quality to 14 RF, audio either disable if there's none, passthrough if it's AAC or convert to 160k opus if you have no idea, disable subtitles and chapters and I guess that's all.

e621:supported_filetypes "..Should be YUV420 8bit.."
Ideally artists themselves would do this from their own software to begin with, but constant quality mode with slow encoding settings should be enough.

howto:transcode and convert if I had any extra time to do shit, already just moved howto:sites and sources away from my profile and others took over it.
Doesn't help that there's so many variables and then software also updates, apparently SVT only had three pass, now has two pass mode, but it's still not exposed to FFmpeg so????

May I send you what file I got, as to avoid getting in trouble by uploading another video file which is incorrect?

mairo said:
https://trac.ffmpeg.org/wiki/Encode/AV1
ffmpeg -i input.mp4 -metadata title="CHANGE THIS TITLE" -metadata comment="CHANGE THIS SOURCE URL" -c:v libsvtav1 -preset 0 -svtav1-params tune=0 -g 150 -pix_fmt yuv420p -crf 14 -an -movflags +faststart output.mp4
On Handbrake, enable "web optimized", disable all resolution limits and anamorphic, all filters off, encoder SVT, FPS same as source and constant, preset to 0, quality to 14 RF, audio either disable if there's none, passthrough if it's AAC or convert to 160k opus if you have no idea, disable subtitles and chapters and I guess that's all.

e621:supported_filetypes "..Should be YUV420 8bit.."
Ideally artists themselves would do this from their own software to begin with, but constant quality mode with slow encoding settings should be enough.

howto:transcode and convert if I had any extra time to do shit, already just moved howto:sites and sources away from my profile and others took over it.
Doesn't help that there's so many variables and then software also updates, apparently SVT only had three pass, now has two pass mode, but it's still not exposed to FFmpeg so????

Also I'm not seeing a pre-set for "YUV420 8bit"

alphamule

Privileged

freakazoid123 said:
I'm new to Handbreak but I'm using it because I was told it would allow me to convert mp4 videos to an appropriate format for e621 with no degradation in quality. It just looks like I've stepped into the cockpit of a Boeing aircraft with all these buttons. I've watched tutorials but none of them are telling me "These are the buttons you want to say these things, for it to work best on e621." If anyone can help me with just figuring out how to correctly convert these videos using this soft ware, it would be much appreciated, and I'd write it down so I do the exact same thing everytime.

This is a great use case for scripting. You copy down the lines you use, and only modify them if you want something changed. Then you can just drag the file on top of the script.
As a bonus, you can also configure frontends to do this for you. Decent ones will list what options they throw at ffmpeg backend. In fact if they don't, that's a bad sign.

Also I'm not seeing a pre-set for "YUV420 8bit"

https://www.videoconverterfactory.com/tips/handbrake-presets.html You can copy an existing one and add that option. It also lets you just use a text file (JSON) to transfer them between PCs. Hmm, maybe we should have a handy list of presets for e621 videos to download on here.

I added some info on how to narrow down to the documentation you want, below.

If you run "ffmpeg -h" without a filename you can list some common options, a lot of options, and damn near all the options. ;) I pasted my steps and results so that others know how to get the information from the program. The online documentation has a lot of the same information, and is maybe easier to read. You can use a program like notepad or nano to read the full dump I linked above. CTRL-F is your friend!

Getting help:
    -h      -- print basic options
    -h long -- print more options
    -h full -- print all options (including all format and codec specific options, very long)
    -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol
    See man ffmpeg for detailed description of the options.

Running "ffmpeg -codecs" gives me:

DEV.L. vp9                  Google VP9 (decoders: vp9 libvpx-vp9 vp9_cuvid vp9_qsv) (encoders: libvpx-vp9 vp9_vaapi vp9_qsv)
DEAIL. opus                 Opus (Opus Interactive Audio Codec) (decoders: opus libopus) (encoders: opus libopus)

Both of them can both encode and decode (DE), VP9 is video (V), Opus is audio (A), both are lossy (L), and I isn't important.
It's telling you what the -encoder and -decoder options support.

Looking up other options Mairo listed:

-vcodec <codec>     alias for -c:v (select encoder/decoder for video streams)
DEV.L. av1                  Alliance for Open Media AV1 (decoders: libdav1d libaom-av1 av1 av1_cuvid av1_qsv) (encoders: libaom-av1 librav1e libsvtav1 av1_nvenc av1_qsv av1_amf av1_vaapi)
 -g                 <int>        E..V....... set the group of picture (GOP) size (from INT_MIN to INT_MAX) (default 12)
-crf               <int>        E..V....... Select the quality for constant quality mode (from -1 to 63) (default -1)
-an                 disable audio
-movflags          <flags>      E.......... MOV muxer flags (default 0) -> faststart                    E.......... Run a second pass to put the index (moov atom) at the beginning of the file

The metadata title/comment tags are pretty nice to have. The preset of 0 is the most aggressive. AV1 has it's own documentation on the parameters like tune (Perception tuning, 0=Visual quality). "Don't worry, just use it." ;) I am not familiar with g but it seems to mess with seeking by rearranging the frame order. Faststart movflag seems much of the same. Quality of life settings for people playing your output videos.

Some (optional) background info on YUV. It explains "4:2:0" part of the name. The 4CC docs linked from there are nice but not really applicable for just wanting to use some tool. We're not writing our own FFMPEG! ;)

alphamule said:
This is a great use case for scripting. You copy down the lines you use, and only modify them if you want something changed. Then you can just drag the file on top of the script.
As a bonus, you can also configure frontends to do this for you. Decent ones will list what options they throw at ffmpeg backend. In fact if they don't, that's a bad sign.

https://www.videoconverterfactory.com/tips/handbrake-presets.html You can copy an existing one and add that option. It also lets you just use a text file (JSON) to transfer them between PCs. Hmm, maybe we should have a handy list of presets for e621 videos to download on here.

I added some info on how to narrow down to the documentation you want, below.

If you run "ffmpeg -h" without a filename you can list some common options, a lot of options, and damn near all the options. ;) I pasted my steps and results so that others know how to get the information from the program. The online documentation has a lot of the same information, and is maybe easier to read. You can use a program like notepad or nano to read the full dump I linked above. CTRL-F is your friend!

Getting help:
    -h      -- print basic options
    -h long -- print more options
    -h full -- print all options (including all format and codec specific options, very long)
    -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol
    See man ffmpeg for detailed description of the options.

Running "ffmpeg -codecs" gives me:

DEV.L. vp9                  Google VP9 (decoders: vp9 libvpx-vp9 vp9_cuvid vp9_qsv) (encoders: libvpx-vp9 vp9_vaapi vp9_qsv)
DEAIL. opus                 Opus (Opus Interactive Audio Codec) (decoders: opus libopus) (encoders: opus libopus)

Both of them can both encode and decode (DE), VP9 is video (V), Opus is audio (A), both are lossy (L), and I isn't important.
It's telling you what the -encoder and -decoder options support.

Looking up other options Mairo listed:

-vcodec <codec>     alias for -c:v (select encoder/decoder for video streams)
DEV.L. av1                  Alliance for Open Media AV1 (decoders: libdav1d libaom-av1 av1 av1_cuvid av1_qsv) (encoders: libaom-av1 librav1e libsvtav1 av1_nvenc av1_qsv av1_amf av1_vaapi)
 -g                 <int>        E..V....... set the group of picture (GOP) size (from INT_MIN to INT_MAX) (default 12)
-crf               <int>        E..V....... Select the quality for constant quality mode (from -1 to 63) (default -1)
-an                 disable audio
-movflags          <flags>      E.......... MOV muxer flags (default 0) -> faststart                    E.......... Run a second pass to put the index (moov atom) at the beginning of the file

The metadata title/comment tags are pretty nice to have. The preset of 0 is the most aggressive. AV1 has it's own documentation on the parameters like tune (Perception tuning, 0=Visual quality). "Don't worry, just use it." ;) I am not familiar with g but it seems to mess with seeking by rearranging the frame order. Faststart movflag seems much of the same. Quality of life settings for people playing your output videos.

Some (optional) background info on YUV. It explains "4:2:0" part of the name. The 4CC docs linked from there are nice but not really applicable for just wanting to use some tool. We're not writing our own FFMPEG! ;)

While all this information is very useful, I lack the brain to actually understand what any of it means.

Do you think you could somehow make a preset for an e621 mp4 video? Something I can just select in Handbreak, and always use that option everytime I have a video to upload to e621. I just need to get convert an mp4 into an mp4 which is compatible with e621 and doesn't cause any degradation in the video quality. As of current, I have 288 videos yet to be uploaded to e621, from Kriskawaii on Furaffinity.

Steps to Convert Videos to MP4 Using FFMPEG on Windows:

  • 1) Go to https://ffmpeg.org/ and click on Download and choose the one for your computer's operating system (e.g., Windows, macOS, Linux).
    • If you are on Windows, you will need to download the full release by clicking here. The "essentials" version will not come with the AV1 codec installed.
  • 2) Extract the compressed zip file into an appropriate folder that you are going to use moving forward. I would suggest simply naming it as "FFMPEG".
  • 3) At this point, you should already have FFMPEG extracted and have the video you wish to convert in hand.
  • 4) (Optional) Open an empty notepad to help you with writing the command. You can skip this step and try inserting directly into Command Prompt if you are proficient enough.
  • 5) In the FFMPEG folder, open the "bin" folder and select ffmpeg.exe (don't double click and launch it, it does nothing). Copy the path of the program onto your clipboard (Google if you don't know how to).
  • 6) Go back to your notepad and press CTRL+V to paste the path. If nothing appears, repeat Step 5 again and make sure you have actually copied something.
    • Command should look like: "C:\Users\...\FFMPEG\bin\ffmpeg.exe".
  • 7) In the folder where you have kept the video, select the video you want to convert (e.g., unconverted_video.mp4) and copy the path to that (similar to Step 5).
  • 8) Go back to your notepad and press space once, followed by typing in -i, and then pressing space once more, and finally pressing CTRL+V to paste the input video's path.
    • Command should look like "C:\Users\...\FFMPEG\bin\ffmpeg.exe" -i "C:\Users\...\unconverted video.mp4".
  • 9) Copy the following -c:v libsvtav1 -preset 0 --svtav1-params tune=0 -g 150 -pix_fmt yuv420p -crf 14 -an -movflags +faststart as suggested on @Mairo's comment.
  • 10) Go back to your notepad and press space once, followed by CTRL+V again to paste the remaining commands.
    • Command should look like "C:\Users\...\FFMPEG\bin\ffmpeg.exe" -i "C:\Users\...\unconverted video.mp4" -c:v libsvtav1 -preset 0 --svtav1-params tune=0 -g 150 -pix_fmt yuv420p -crf 14 -an -movflags +faststart.
  • 11) Find a suitable folder for where you want your converted file to be. In this case, I will demonstrate by putting it in the same folder as the unconverted video.
  • 12) Repeat Step 7.
  • 13) Go back to your notepad and press space once, followed by CTRL+V to paste the output video's path.
    • Command should look like "C:\Users\...\FFMPEG\bin\ffmpeg.exe" -i "C:\Users\...\unconverted video.mp4" -c:v libsvtav1 -preset 0 --svtav1-params tune=0 -g 150 -pix_fmt yuv420p -crf 14 -an -movflags +faststart "C:\Users\...\unconverted video.mp4".
  • 14) Edit the output video's path and rename the file to something else. It should not be the same as the unconverted video. In this case, I'll rename it to converted_video.mp4.
    • Command should look like "C:\Users\...\FFMPEG\bin\ffmpeg.exe" -i "C:\Users\...\unconverted video.mp4" -c:v libsvtav1 -preset 0 --svtav1-params tune=0 -g 150 -pix_fmt yuv420p -crf 14 -an -movflags +faststart "C:\Users\...\converted video.mp4".
  • 15) Launch the Command Prompt program by searching for cmd on your Windows search. A black window should pop up with C:\Windows\system32> typed in.
  • 16) Copy the entire command from your notepad and press CTRL+V to paste it onto the Command Prompt.
    • Final command should look like C:\Windows\system32>"C:\Users\...\FFMPEG\bin\ffmpeg.exe" -i "C:\Users\...\unconverted video.mp4" -c:v libsvtav1 -preset 0 --svtav1-params tune=0 -g 150 -pix_fmt yuv420p -crf 14 -an -movflags +faststart "C:\Users\...\converted video.mp4".
  • 17) Press Enter to begin the conversion process. It may take a while.
  • 18) The conversion is complete once you see C:\Windows\system32> blinking again, and the file should be next to where you had saved your unconverted video.
    • If it is not there or if you had simply put the output path as output.mp4, check whatever directory your Command Prompt program is in. The path shown in Step 15 or Step 18 should be where it is located.
  • 19) (Optional) If you want to add the post's title and URL into the video's metadata, you can simply open the file's properties, open the Details tab, insert them directly into the Description section (i.e., the post's title under "Title" and the post's URL under "Comments"), and press Apply to save the changes.
  • 20) If you had saved the command on a notepad, you can simply replace the input/unconverted video's path and the output/converted video's path for any new conversions you want to make.

freakazoid123 said:
While all this information is very useful, I lack the brain to actually understand what any of it means.

Do you think you could somehow make a preset for an e621 mp4 video? Something I can just select in Handbreak, and always use that option everytime I have a video to upload to e621. I just need to get convert an mp4 into an mp4 which is compatible with e621 and doesn't cause any degradation in the video quality. As of current, I have 288 videos yet to be uploaded to e621, from Kriskawaii on Furaffinity.

If you are using constant quality mode, generally speaking, yes.
Practically you might need to change the quality depending on source material, adjust audio settings per video basis, if it's long form video you might need to change to constrained bitrate and use higher preset so it doesn't take two days to handle, etc.

This artists videos are really good bitrate, so use really low CRF/RF value, on scale of like 8-14, usually testing material for general video hosting site rips and medium quality videos around 16 is OK, some really poor source material going up to 21 might still be fine, 27 is way too high for purposes of preserving content as high quality as possible.

thegreatwolfgang said:
Steps to Convert Videos to MP4 Using FFMPEG on Windows:
<too many steps>

You can navigate away from system32, just cd to folder instead.
Instead of copying whole complete paths to literally everything, put the binary executable in %PATH% so you can simply use ffmpeg as command and open CLI on the folder where your files to work with are, on Windows 11 it's right clicking on folder context menu or write cmd or powershell on the address bar just to name couple fast methods.
Also you can literally put comments and titles with FFmpeg directly, without needing to modify the file after conversion.

mairo said:
You can navigate away from system32, just cd to folder instead.
Instead of copying whole complete paths to literally everything, put the binary executable in %PATH% so you can simply use ffmpeg as command and open CLI on the folder where your files to work with are, on Windows 11 it's right clicking on folder context menu or write cmd or powershell on the address bar just to name couple fast methods.
Also you can literally put comments and titles with FFmpeg directly, without needing to modify the file after conversion.

Alright, you're welcome to write an even more simplified step-by-step version for @Freakazoid123 to follow.