Live data from Hacker News

FFmpeg 4.4

ffmpeg.org

111–120 of 135 posts

Re: FFmpeg 4.4

#111
post #79

ffmpeg is the best tool ever with the worst documentation ever.

This is why I also use MP4Box, as it's often a lot easier to get something done that I just can't manage to with ffmpeg.

Re: FFmpeg 4.4

#112

I think everyone was a txt file on their computer filled with FFmpeg commands. Care to share yours?

# Encode for Apple, 720p

ffmpeg -i snow.mp4 -c:v libx265 -preset slow -crf 28 -tag:v hvc1 -c:a aac -ac 2 -b:a 128k -vf scale=1280:-1 snow.mov

# Merge video from one file, audio from another, trimmed

ffmpeg -i video.mp4 -i audio.mp4 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 -to 00:00:41 merged.mp4

# Trim a video

ffmpeg -ss 00:06:58 -to 00:08:26 -i TeSiJmLoJd0.webm bbf.mp4

Re: FFmpeg 4.4

#114
post #102
post #90

Earlier quoted context omitted.

Downmixes audio on movies from surround sound to stereo balanced for night watching (prevents audio being too quiet) so that they can direct stream on my devices ffmpeg -hide_banner -loglevel error -nostdin -y -i "$f" -map 0:0 -c:v copy -map 0:a:0? -c:a:0 aac -b:a:0 160k -filter:a:0 "pan=stereo|FL=1.414*FC+0.707*FL+0.5*FLC+0.5*BL+0.5*SL+0.5*LFE|FR=1.414*FC+0.707*FR+0.5*FRC+0.5*BR+0.5*SR+0.5*LFE,acompressor=ratio=4" -…

Goddammit I can't believe how downmixing x.y to 2.0 isn't a solved problem by now and is so broken through and through. I mean, it's never ever done in a way that doesn't produce quiet dialog that makes you raise volume and loud sounds that makes your eardrums bleed. Like, even basic audio normalisation would produce half-decent results, but no we get crazy contrast by default and constant volume switching.

The interesting part is that most media is being consumed with stereo audio down-mixing. Everyone streaming content on their laptops, with their television's speakers or with a sound bar. Yet all the audio is recorded and mastered for surround sound systems, even though they could include mastered stereo audio without the down-mixing issues like quiet audio.

Re: FFmpeg 4.4

#115

I think everyone was a txt file on their computer filled with FFmpeg commands. Care to share yours?

This one just add a 5 second title to the video taking the name from the file name

#!/bin/bash

#Creates a Directory

mkdir -p titles

#loop for files in folder

for f in .MOV; do

    text="${f%.MOV}"     
               
#Uses drawtext

    ffmpeg -i "$f" -vf drawtext="fontfile=/usr/share/fonts/opentype/NotoSansCJK-Regular.ttc  : \
text=$text : fontcolor=white: fontsize=82: box=1: boxcolor=black@0.5: \ boxborderw=20: x=(w-text_w)/2:y=h-th-40 :enable='between(t,0,5)'" -codec:a copy "./titles/$f" done # Other options:

# Bottom center: x=(w-text_w)/2:y=h-th (with 10 px padding: x=(w-text_w)/2:y=h-th-20)

# centered: x=(w-text_w)/2: y=(h-text_h)/2

This is my trim tool to cut beginnings and/or endings of files

#!/bin/bash

mkdir -p trimmed

duration=$(ffmpeg -i "$1" 2>&1 | grep "Duration"| cut -d ' ' -f 4 | sed s/,//)

length=$(echo "$duration" | awk '{ split($1, A, ":"); print 3600A[1] + 60*A[2] + A[3] }' )

trim_start="$2"

trim_end=$(echo "$length" - "$3" - "$trim_start" | bc)

ffmpeg -ss "$trim_start" -i "$1" -c copy -map 0 -t "$trim_end" "./trimmed/$1"

# Example # >trim example.MOV 0.2 10

Re: FFmpeg 4.4

#116
post #103
post #94

Earlier quoted context omitted.

FFmpeg, curl, and NumPy epitomizes the concept of “Do One Thing and Do it Well.”

What exactly is ffmpeg's one thing? Or curl's for that matter?

Curl's "one thing" is to get files from the network in every conceivable way possible. Ffmpeg's is to convert media files between every conceivable set of formats possible.

Re: FFmpeg 4.4

#117
post #66

I think everyone was a txt file on their computer filled with FFmpeg commands. Care to share yours?

I have one glorious: ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -vf "hwdownload,format=nv12,scale=(iw*sar)*max(1280/(iw*sar)\,720/ih):ih*max(1280/(iw*sar)\,720/ih), crop=1280:720, subtitles=input.srt:force_style='FontName='TiresiasScreenfont',Fontsize=32,Outline=2,MarginL=50,MarginV=30,Alignment=1',minterpolate=fps=60:mi_mode=blend" -c:v h264_nvenc -preset slow -b:v 8M -f matroska - | vlc - What it does: Allo…

According to Yle they only started using Tiresias in 2012. The article doesn't mention which font they were using before. I would be interested in their 90s font as well.

Source: https://yle.fi/aihe/artikkeli/2012/01/27/televisiokanavien-t...

Re: FFmpeg 4.4

#118
post #88
post #71

We're all thinking it, but holy cow is FFmpeg one of the craziest pieces of software I have on my computer. The amount of neat things I've been able to do with it and toss them into a bash loop and go to bed is incredible. I'm sure a lot of us get a kick out of automating our tasks, and FFmpeg is king when it comes to that.

ffmpeg and curl are two open source products I just tip my hat to.

I'd like to add exiftool to this list.

Re: FFmpeg 4.4

#119
post #88
post #71

We're all thinking it, but holy cow is FFmpeg one of the craziest pieces of software I have on my computer. The amount of neat things I've been able to do with it and toss them into a bash loop and go to bed is incredible. I'm sure a lot of us get a kick out of automating our tasks, and FFmpeg is king when it comes to that.

ffmpeg and curl are two open source products I just tip my hat to.

jq is a neat young one on this list I think

also at the metalevel, gnu parallel

Re: FFmpeg 4.4

#120

I think everyone was a txt file on their computer filled with FFmpeg commands. Care to share yours?

Back in 2004, someone released an unauthorized fan dub/narration of the the first Harry Potter movie called Wizard People, Dear Reader that hilariously butchers the entire plot, character names, and motivations. This narration is (loosely) synced to the movie and its scenes, and for a long time I watched it via clips uploaded to YouTube. But when Sorcerer’s Stone got a 4K release, I decided it was time to rip it and create my own canonical copy.

The original audio files of the dub were at this point still available on archive.org. The problem is that the second audio file is not meant to play directly after the first - this was back in the days of CD players, so halfway through the movie the dub instructs you to begin playing the second CD once the next scene starts. The other problem is that the second file is louder than the first.

Most sources I saw online said to insert a gap of three seconds to account for the delay, and didn’t have a solution for the difference in volume. I wanted to be more precise.

First, I found the exact start time of the scene where the second audio track begins:

    ffprobe hp.mkv
    ...
        Chapter #0:18: start  4428.882000, end 4817.521000
        Metadata:
          title           : Chapter 19
    ...
Then I compared this with the duration of the first audio track:

    ffprobe wiz1.mp3
    ...
      Duration: 01:13:45.33, start: 0.000000, bitrate: 66 kb/s
    ...
The difference between these time stamps gave the actual delay of 3.582 seconds.

I then compared the maximum audio levels of the two audio tracks to determine the level to increase the first track’s volume by (there are more advanced features in FFmpeg for volume normalization, but I just wanted to remove the potential for eardrum damage when beginning Chapter 19 and keep things as similar as possible otherwise):

    ffmpeg -i wiz1.mp3 -af volumedetect -f null -
    [Parsed_volumedetect_0 @ 000001ecf871c1c0] max_volume: -11.1 dB

    ffmpeg -i wiz2.mp3 -af volumedetect -f null -
    [Parsed_volumedetect_0 @ 000001858b881880] max_volume: -3.6 dB
This gave me the volume increase for the first track of 7.5 dB.

Once I had these numbers, it was time for the one-liner to adjust the first track’s volume, concatenate the two tracks with the gap of silence, and mux them with the video from the movie:

    ffmpeg -i hp.mkv -i wiz1.mp3 -i wiz2.mp3 -filter_complex "[1]volume=7.5dB[wiz1];aevalsrc=0:duration=3.582:sample_rate=22050[gap];[wiz1][gap][2]concat=n=3:v=0:a=1,apad[wiz]" -map 0 -map "[wiz]" -shortest -c:v copy -c:a flac -sample_fmt s16 -f matroska wiz.mkv
Post reply on HN