Live data from Hacker News

FFmpeg 4.4

ffmpeg.org

101–110 of 135 posts

Re: FFmpeg 4.4

#101

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

Very Carefully Rebuild a Video

# H264

    $ ffmpeg -i input.avi -c copy -c:v libx264 -crf 18 -preset slow output.mkv
# H265

    -c:v libx265 -crf 22
Append Subtitles

    $ ffmpeg -i input.mkv -i input.srt -map 0 -map 1 -c copy output.mkv
Concat Videos

    $ ls *.mkv > mylist.txt
    $ vim mylist.txt # append each line with "file "
    $ ffmpeg -f concat -i mylist.txt -c copy merged-pre-subbed.mkv
Probe size issues?

     $ ffmpeg -analyzeduration 2147483647 -probesize 2147483647 ...
Deinterlace

    -vf yadif
Metadata Examples

    ffmpeg -i foo.avi -i commentary.mp3 -map 0 -map 1 -c:a copy -c:v libx264 -crf 18 -preset fast  -metadata:s:a:1 title="Commentary" -metadata:s:a:0 language=eng  funk.mkv
Autocrop

    $ ffplay -i foo.mkv -vf "cropdetect=24:16:0"

    

    [Parsed_cropdetect_0 @ 0x7ff093c65c00] x1:0 x2:1919 y1:132 y2:947 w:1920 h:816 x:0 y:132 pts:30155 t:30.155000 crop=1920:816:0:132

    -filter:v:0 "crop=1920:816:0:132"

Re: FFmpeg 4.4

#102
post #90

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

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.

Re: FFmpeg 4.4

#103
post #94
post #88

Earlier quoted context omitted.

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

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?

Re: FFmpeg 4.4

#104

Earlier quoted context omitted.

The use cases are so diverse that adding a UI for all use cases is near impossible. I also built a UI for ffmpeg, but mine was geared towards creating and applying video filters - much like Lightroom presets.

Sounds cool is it on github?

Its proprietary

Re: FFmpeg 4.4

#105

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

Annotate video with frame numbers:

  ffmpeg -i input.mp4 -vf "drawtext=fontfile=font.ttf: text=%{n}: x=48: y=48: fontcolor=white: box=1: boxcolor=0x00000099: fontsize=72" -y output.mp4
Remove audio track from video:

  ffmpeg -i input.mp4 -c copy -an output.mp4

Re: FFmpeg 4.4

#106

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

Not an ffmpeg wizard here, but here are my screencasting commands. Probably the most useful knowledge in this snippet is how to use Alsa from ffmpeg; i.e., Alsa devices can be referred to as hw:0, hw:1, etc; and one finds out which device to use from arecord.

  # Example output file.
  f=/tmp/output.mp4

  # Example video resolution.
  g=1920x1080

  # Example capture framerate
  fr=4

  # Example X11 display
  d=$DISPLAY

  # Simple screencast.
  #
  # Try adjusting the libx264 CRF from 15 to some greater number, as long
  # as there is no visible effect on video quality.
  #
  # If increasing the capture framerate, you may also wish to use a
  # faster preset.
  ffmpeg  -probesize 50M  -f x11grab -video_size "$g" -framerate "$fr" -i "$d"    \
         -c:v libx264 -crf 15 -preset veryslow   "$f"

  # Simple screencast without drawing the pointer/cursor.
  ffmpeg  -probesize 50M  -f x11grab -video_size "$g" -framerate "$fr" -draw_mouse 0 -i "$d"      \
         -c:v libx264 -crf 15 -preset veryslow   "$f"

  # See what devices are available for capturing sound.
  arecord -l

  # Select a device.
  audioCaptureDevice=hw:0

  # List some permitted parameters associated with device 0.
  #
  # We are interested in the "FORMAT", "CHANNELS", and "RATE" parameters
  # for use in the ffmpeg command.
  arecord --dump-hw-params -D "$audioCaptureDevice"

  audioSampleFormat=pcm_s32le
  audioNumChannels=2
  audioRate=44100

  f=/tmp/output.mp3

  # Record sound.
  ffmpeg  -thread_queue_size 8192 -f alsa -channels "$audioNumChannels" -sample_rate "$audioRate" \
         -c:a "$audioSampleFormat" -ar "$audioRate" -i "$audioCaptureDevice" "$f"

  f=/tmp/output.mkv

  # Screencast with sound.
  #
  # Note that there seems to be an FFMPEG bug where the audio in the last
  # 15 seconds of the video is cut off. The workaround is to record for
  # 15 exrtra seconds, and then cut the extra video.
  ffmpeg  -probesize 50M  -f x11grab -video_size "$g" -framerate "$fr" -i "$d"                    \
         -thread_queue_size 8192 -f alsa -channels "$audioNumChannels" -sample_rate "$audioRate" \
         -c:a "$audioSampleFormat" -ar "$audioRate" -i "$audioCaptureDevice"                     \
         -c:a flac -c:v libx264 -crf 17          "$f"

Re: FFmpeg 4.4

#107
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 does loads of stuff, supports so many protocols - HTTP, LDAP, FTP etc.

Re: FFmpeg 4.4

#108
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?

CLI video editing

Make web requests

Re: FFmpeg 4.4

#109
post #55

Earlier quoted context omitted.

It’s a lot like how Linux supports the N64, right? If someone wants to write and maintain the code, it can get upstreamed.

But what are the odds that obscure formats like this will be implemented (and maintained) without security holes? I vaguely remember an exploit where the GNOME file viewer would automatically preview samples of any audio file that (I think) gstreamer could recognise, and one of those formats was something like a NES audio format, whose implementation had some buffer overflows in it. Are there similar concerns with ff…

Running ffmpeg on untrusted input outside of a sandbox you trust to be secure is an extremely bad idea. It doesn't have a good track record for that, and making it safe to use ffmpeg on untrusted input has never been a priority for the project.

In practice things like video hosting services which use ffmpeg internally tend to disable support for most of the obscure file formats to reduce the potential attack surface.

Re: FFmpeg 4.4

#110

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

Extract audio from all my downloaded YT .webm videos to .opus:

  for i in *.webm ; do echo "$i";ffmpeg -i "$i" -acodec copy -vn "${i%.*}.opus" ; done
Nothing fancy.
Post reply on HN