• 0 Posts
  • 18 Comments
Joined 2 years ago
cake
Cake day: July 17th, 2024

help-circle
    • When does 4 become 5?

    4.5 >=? Lots of programming languages define casting as the largest integer value, not the the rounded value. Outside of programming, there are scenarios where 4 cannot be rounded to 5 either… Like a height requirement for a ride at an amusement park. Though, it might seem natural to round it to humans.

    • When does green become black in a gradient?

    With computer languages, we define colors with red, blue, and green. The above is a gradient on horizontal x-axis, with

    (r = 0, g = x, b = 0) 
    

    This is more complicated. If we surveyed 1 million people, maybe we’d get a plot that defined the start of green as something like the following.

    And then maybe we could take the the average and state that as green.

    Though, is that really good enough description of green to serve as a legal definition of green? Maybe lawyers would select significantly different results than the general population when surveyed for the value of green. Maybe the results should be restricted to lawyers?

    • And when does 2 become 7?

    If we restricted it pixels to a 3x5 grid…

    We could possibly define 2 and 7.

    But then is this a 2 or a 7?





  • 0t79JeIfK01RHyzo@lemmy.mltoLinux@lemmy.ml*Permanently Deleted*
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    25 days ago

    It’s easy to build most flatpaks on flathub into bundles from source.

    An example building KDE's weather application from source
    # Setup for building bundles
    sudo apt install flatpak flatpak-builder git
    flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
    flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
    
    # Building flatpak bundles from source code
    git clone https://github.com/flathub/org.kde.kweather 
    cd org.kde.kweather
    flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo builddir org.kde.kweather.json
    flatpak build-bundle repo org.kde.kweather.flatpak org.kde.kweather
    
    # Installing the build on any device that has completed setup
    flatpak install -y --user ./org.kde.kweather.flatpak
    
    # Running the installed flatpak
    flatpak run org.kde.kweather
    

    The flathub organization account contains everything needed for most applications on flathhub

    https://github.com/flathub

    edit: I write code sometimes, and building projects from source is often a painful process that can feel overwhelming and hopeless at times. I was really impressed when I realized this was possible, and went and built some of my favorite applications from source afterwards.









  • I don’t know what these people are doing who seem to claim it’s wonderful. Every single time I have tried to use one, it’s been completely clueless about the problem and wastes my time producing slop. I almost want to keep my code closed source because of how awful it is at generating anything. Maybe they’re just doing very simple web design or something, I don’t know

    I even have started to hate Google and felt like their search engine is becoming very bad. Yandex has been returning more results and Google feels censored and replaced by generative AI answers.


  • Sometimes it’s specific to the application. As an example, yt-dlp is redistributed by Canonical, and they usually maintain stable packages, but their versions seem to lag like 6 months. This might be related to their desire for stability, or maybe just align to their release cycle. I don’t know.

    The issue is that yt-dlp needs to be updated more frequently because websites break their methods of downloading, so the version that follows the latest version seems to work better.

    I don’t think using PPA’s is usually recommended, (like in the photo) so I think I would recommend flatpaks first if the developer of the application maintains one themselves. (and you want to follow later releases.) Though, the first time I had to use flatseal to fix an application, I felt like flathub was a failed platform.






  • I might add one for scaling. I just don’t use it as frequently as trying to meet a file size limit. The scaling is also much easier to remember

    ffmpeg -i  in.mp4 -vf "scale=600:-1" -an out.mp4
    

    It does get complicated though, when scaling many videos and images, I’ve used something like the following in the past

    find .  -exec ffmpeg -i {} -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1:color=black" {}.mp4 \;
    

    Those were the only two that showed up when I typed history | grep scale.

    after commenting, I also added a new video file resizer.

    It works significantly better than the one I previously posted. It’s also copied from stackoverflow.

    bitrate="$(awk "BEGIN {print int($2 * 1024 * 1024 * 8 / $(ffprobe \
        -v error \
        -show_entries format=duration \
        -of default=noprint_wrappers=1:nokey=1 \
        "$1" \
    ) / 1000)}")k"
    ffmpeg \
        -y \
        -i "$1" \
        -c:v libx264 \
        -preset medium \
        -b:v $bitrate \
        -pass 1 \
        -an \
        -f mp4 \
        /dev/null \
    && \
    ffmpeg \
        -i "$1" \
        -c:v libx264 \
        -preset medium \
        -b:v $bitrate \
        -pass 2 \
        -an \
        "${1%.*}-$2mB.mp4"
    

  • The version I have was copied from stackoverflow. It doesn’t work very well, it makes a rough estimate to get the video file size under the set value. As an example

    resize video.mp4 10
    

    Which then resizes the video to 10 megabytes if possible.

    resize.sh code
    file=$1
    target_size_mb=$2  # target size in MB
    target_size=$(( $target_size_mb * 1000 * 1000 * 8 )) # target size in bits
    length=`ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file"`
    length_round_up=$(( ${length%.*} + 1 ))
    total_bitrate=$(( $target_size / $length_round_up ))
    audio_bitrate=$(( 128 * 1000 )) # 128k bit rate
    video_bitrate=$(( $total_bitrate - $audio_bitrate ))
    ffmpeg -i "$file" -b:v $video_bitrate -maxrate:v $video_bitrate -bufsize:v $(( $target_size / 20 )) -b:a $audio_bitrate "${file}-${target_size_mb}mb.mp4"
    

    I’ll probably replace it eventually.