Giter VIP home page Giter VIP logo

Comments (8)

NotQuiteApex avatar NotQuiteApex commented on August 22, 2024

Bit of a lapse in brainulating today. Because VodBot deals in MP4's, and uses -c copy with ffmpeg, its purely a CPU operation simply copies data from one file to another. Closing.

from vodbot.

NotQuiteApex avatar NotQuiteApex commented on August 22, 2024

After thinking it over for a while, I've discovered that the above comment can be incorrect in cases where videos from multiple different source files can lead to mixing formats and bitrates, which in turn leads to potentially catastrophic video errors.

It's very much worth looking into potential external hardware encoders, although configuration of these encoders in the ffmpeg commands can be tricky.

Note to self: search any and all direct drop-in strings for potential security issues.

from vodbot.

NotQuiteApex avatar NotQuiteApex commented on August 22, 2024

Some useful encoding params...

  • ffmpeg -i input.avi -c:v libx264 output.mp4 # Software H.264
  • ffmpeg -i input.avi -c:v libx265 output.mp4 # Software HEVC/H.265
  • ffmpeg -i input.avi -c:v h264_amf output.mp4 # AMD Accel. H.264
  • ffmpeg -i input.avi -c:v hevc_amf output.mp4 # AMD Accel. HEVC/H.265
  • ffmpeg -i input.avi -c:v h264_qsv output.mp4 # Intel Accel. H.264
  • ffmpeg -i input.avi -c:v hevc_qsv output.mp4 # Intel Accel. HEVC/H.265
  • ffmpeg -i input.avi -c:v av1_qsv output.mp4 # Intel Accel. HEVC/H.265
  • ffmpeg -i input.avi -c:v h264_nvenc output.mp4 # Nvidia Accel. H.264
  • ffmpeg -i input.avi -c:v hevc_nvenc output.mp4 # Nvidia Accel. HEVC/H.265

This is specifically for the output, video decoders must be specified with -c:v decoder_here before the -i input.avi arguments.

from vodbot.

NotQuiteApex avatar NotQuiteApex commented on August 22, 2024

https://trac.ffmpeg.org/wiki/HWAccelIntro

Seems like hardware acceleration on Linux for AMD is meant to use VAAPI, as it at least has partial support. Instead of custom parameters from config it may be safer to simply provide a config variable with "nvidia-264", "amd-265", "intel-av1", etc. as options.

from vodbot.

NotQuiteApex avatar NotQuiteApex commented on August 22, 2024

So for determining decode type for using hw acceleration, ffmpeg has a side program called ffprobe that can find useful info from a file. So ffprobe -v quiet -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey= 1 /mnt/archive/vods/notquiteapex/2022-12-10T23\;01\;47Z_1675749547.mkv will return "h264", which python will need to grab to determine how to decode the file. Most if not all twitch streams will be h264.

from vodbot.

NotQuiteApex avatar NotQuiteApex commented on August 22, 2024

SO! VAAPI is exclusive to Linux, and in my testing it is not at all necessary for using AMD hardware acceleration on Linux, and that the FFmpeg wiki is simply out of date.

I'm thinking of two config options to add, first is hwaccel_encoder (options are "software", "amd", "intel", and "nvidia"), next is hwaccel_decoder (same as before), and hwaccel_format (options are "h264", "hevc", and "av1"). The first two options handle how the video is managed, the last option handles how the videos are saved to the system and how they should be expected to be handled when local. There would probably be ffprobe checks in place to make sure that the expected and actual formats, though.

from vodbot.

NotQuiteApex avatar NotQuiteApex commented on August 22, 2024

Internally, there would simply be a multidimensional dictionary that handles translating the codec and format options to their respective ffmpeg options (like "av1" and "intel" translating to "av1_qsv"). This would not be a simple string manipulation, due to the weird/different names that ffmpeg uses for codecs and formats (h265 is hevc but not by name, intel is qsv, etc).

MKV's will still be used because its a great container format.

from vodbot.

NotQuiteApex avatar NotQuiteApex commented on August 22, 2024

Lastly, subprocess.run can redirect stdout to a useful output that isn't the stdout of VodBot. it would simply be using subprocess's pipe object to get the bytes data out of the programs stdout. See here https://csatlas.com/python-subprocess-run-stdout-stderr/

from vodbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.