• 4 Posts
  • 174 Comments
Joined 1 year ago
cake
Cake day: June 24th, 2023

help-circle
  • I despise Docker Desktop. Before I knew anything about docker or containers, all I knew was that it was in the required software list for my work for building our software. All I knew was that if it wasn’t open, my build would fail and if it was open, my laptop would slow down to a crawl.

    Eventually I took classes on Docker for work and learned quite a bit about it. I learned that I could use docker from command line with no UI, and I wouldn’t take anywhere near the performance hit. I eventually linked my IDE docker runtime to podman running on WSL2. Now I take pretty much no noticable performance hit.

    TL;DR: you can replace Docker Desktop with WSL2 command line commands and have no UI.






  • Do you do any scripts beyond extremely simple ones?

    I do a fuck ton of scripting in both bash and python. I never want to do string manipulation in bash. As soon as string manipulation is required, I automatically choose python for a script. Also, if I need named arguments or multiple levels of arguments for subcommands. You can use sys.argv for basic args, which isn’t any harder than bash arguments, but for complex inputs, argparse is a godsend. It has a bit of a learning curve, but it can handle anything. Bash requires you to write complex arg handling manually with loops and reducing.



  • Your reminder worked! Here is the command I used. I put it in a script, and would pass it the file I wanted to convert.

    ffmpeg -i "$1" -vcodec libx265 -crf 28 -map 0 -c:s copy "${1%.*}.h265.mkv" > ./convert_logs 2>&1 < /dev/null &

    If I called this script convert_to_h265.sh, I would call it with convert_to_h265.sh some_video.mkv

    Here is an explanation for the options I used:

    ffmpeg is the command
    -i "$1" is the input file. In this case, the argument to the script
    -vcodec libx265 is specifying the plugin to use as libx265
    -crf 28 is specifying the quality/compression rate. I found this one to be pretty acceptable
    -map 0 makes it select ALL audio tracks and ALL subtitle tracks
    -c:s copy copies subtitle tracks
    "${1%.*}.h265.mkv" specifies the output file. In this case, everything up to the last dot, then replace the extension with ‘.h265.mkv’
    > ./convert_logs 2>&1 < /dev/null tells the program to output to a log file instead of writing to your terminal. It also sets the input to nothing, and without that, it won’t work in a script for some reason.
    & tells the whole thing run in the background so it doesn’t hold up your terminal. You can even close your terminal and do other things and check back on it later.

    You can monitor the progress with tail -f convert_logs

    If you want to get fancy, you can even put this in a loop to run on all the files that end in .mkv in the current directory:

    for i in *.mkv; do
           ffmpeg -i "$i" -vcodec libx265 -crf 28 -map 0 -c:s copy "${i%.*}.h265.mkv" > ./convert_logs 2>&1 < /dev/null
    done
    

    And if you want to get mega fancy, you can have it run recursively for all files that end in .mkv in the current directory and all files in all child directories.

    shopt -s globstar
    for i in **/*.mkv; do
            ffmpeg -i "$i" -vcodec libx265 -crf 28 -map 0 -c:s copy "${i%.*}.h265.mkv" > ./convert_logs 2>&1 < /dev/null
    done
    

    If you do either of the latter two, I would put it in a script. Let’s call the first one convert_all_to_h265.sh and the second one convert_all_to_h265_recursively.sh. Call them with convert_all_to_h265.sh & and convert_all_to_h265_recursively.sh & if you want to run them in the background.

    You also might want to play around with the -crf 28 value if you want more compression or more quality. The lower the number, the better the quality. It needs to be a value between 0 and 51.