Live data from Hacker News

FFmpeg 4.4

ffmpeg.org

21–30 of 135 posts

Re: FFmpeg 4.4

#21

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

mine:

  h264:
  -c:v libx264 -preset medium -crf 22

  h265:
  -c:v libx265 -preset medium -crf 26

  no recompress:
  -c copy

  presets:
  ultrafast,superfast, faster, fast, medium, slow, slower, veryslow

  desinterlace:
  -vf yadif

  target size:
  -s 1920x1080

  aspect ratio without recompressing:
  -aspect 16:9

  rotate video:
  -vf "transpose=1"
  0 = 90CounterCLockwise and Vertical Flip (default)
  1 = 90Clockwise
  2 = 90CounterClockwise
  3 = 90Clockwise and Vertical Flip

  rotate without recompressing:
  -metadata:s:v rotate="90"

  audio aac two channels:
  -c:a aac -b:a 160k -ac 2

  web fast start:
  -movflags +faststart

  autoscale to WxH with black bands:
  -vf "scale=W:H:force_original_aspect_ratio=decrease,pad=W:H:(ow-iw)/2:(oh-ih)/2"

  get jpeg snapshot:
  -vframes 1 -q:v 2 dest.jpg

  concatenate mp4 without recompressing:
  -f concat -safe 0 -i "files.txt" -c copy -movflags +faststart
  files.txt format:
  file 'filepath'

  ffprobe get videoinfo:
  ffprobe -v quiet -print_format xml -show_format -show_streams "filepath" > file.xml

  if override which sub track is default, use "-default_mode infer_no_subs"

  clear disposition (default sub):
  -disposition:s 0

  default or forced disposition:
  -disposition:s forced

  track metadata (audio):
  -metadata:s:a title="xx"
  track metadata (video):
  -metadata:s:v title="xx"
  global metadata:
  -metadata title="xx"
  -metadata description="xx"
  -metadata comment="xx"

  extract sound from video to mp4
  ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192k -f mp3 sound.mp3

  skip time (place after input file):
  -ss 00:05:00

  stop after:
  -t 00:05:00 

  Approx fast seek (place before input file):
  -ss 00:05:00 -noaccurate_seek -i ....

Re: FFmpeg 4.4

#22

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

I only have one, and it's for a rather niche use: fixing incorrect or missing h264/h265 bitstream metadata without re-encoding, for example:

    ffmpeg -i source.avc -c copy -bsf:v h264_metadata=colour_primaries=1:matrix_coefficients=1 output.h264
https://ffmpeg.org/ffmpeg-bitstream-filters.html#h264_005fme... https://www.itu.int/rec/T-REC-H.264-201906-I/en

Re: FFmpeg 4.4

#23

Sadly, HDR passthrough is still an open issue from 3 years ago: https://trac.ffmpeg.org/ticket/7037 I really hoped they could complete this behemoth of a task.

Looking at the comments in that ticket, I can understand why ffmpeg developers don't want to help those people, and the devs probably spoiled more time answering this annoying person than it would take to have fixed the issue, making them lose all motivation to work on that issue.

Re: FFmpeg 4.4

#24

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

    ffmpeg -i foo.mp4 -c:v h264_videotoolbox -b:v 1600k foo_out.mp4
On macOS, this uses hardware acceleration to reencode a video at a lower bitrate. My macbook is from 2012, so this does make a notable difference. There's also "hevc_videotoolbox" for H.265 if your machine supports it.

Re: FFmpeg 4.4

#25
Does anyone know what this is about?

Microsoft Paint (MSP) version 2 decoder

Microsoft Paint (MSP) demuxer

Re: FFmpeg 4.4

#28

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

Video to GIF

  SET filters="fps=%4,scale=%3:-1:flags=lanczos"
  ffmpeg -v warning -i %1 -vf "%filters%,palettegen" -y palette.png
  ffmpeg -v warning -i %1 -i palette.png -lavfi "%filters% \[x\]; \[x\]\[1:v\] paletteuse" -y %2
  DEL palette.png

  togif.bat    
Extract audio from a video

  ffmpeg -i "path\to\my_input_video_file.mp4" "path\to\my_output_audio_only.wav"
Extract specific video and audio stream

  ffmpeg -i "path\to\my_input_video_file.mp4" -map 0:0 -c copy video.mp4 -map 0:1 -c copy audio0.m4a -map 0:2 -c copy audio1.m4a
Concatenate two or more video clips

  (echo file 'first file.mp4' & echo file 'second file.mp4' )>list.txt
  ffmpeg -safe 0 -f concat -i list.txt -c copy output.mp4
Convert 10-bit H.265 to 10-bit H.264

  ffmpeg -i input -c:v libx264 -crf 18 -c:a copy output.mkv
Convert 10-bit H.265 to 8-bit H.265

  ffmpeg -i input -c:v libx265 -vf format=yuv420p -c:a copy output.mkv
Convert 10-bit H.265 to 8-bit H.264

  ffmpeg -i input -c:v libx264 -crf 18 -vf format=yuv420p -c:a copy output.mkv

Re: FFmpeg 4.4

#30

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

Gladly. There's even some relatively advanced stuff in there:

  # Save a RTSP stream to file
  ffmpeg -i rtps://someserver/somevideo -c copy out.mp4

  # encoding quality settings examples
  #   H264
  ffmpeg -i input.mp4 -a:c copy -c:v libx264 -crf 22 -preset slower -tune film -profile:v high -level 4.1 output.mp4
  #   H264 10bit (must switch to a different libx264 version)
  LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/x264-10bit ffmpeg -i input.mp4 -a:c copy -c:v libx264 -crf 22 -preset slower -tune film -pix_fmt yuv420p10le -profile:v high10 -level 5.0 output.mp4

  # resize 
  ffmpeg -i in.mp4 -s 480x270 -c:v libx264 out.mp4

  # change source fps
  ffmpeg -r 10 -i in.mp4 out.mp4

  # resample fps
  ffmpeg -i in.mp4 -r 10 out.mp4

  # extract the audio from a video
  ffmpeg -i inputfile.mp4 -vn -codec:a copy outputfile.m4a

  # merge audio and video files
  ffmpeg -i inputfile.mp4 -i inputfile.m4a -codec copy outputfile.mp4

  # cut (reencoding)
  #   set the start time and duration as HH:MM:SS
  ffmpeg -ss 00:00:40.000 -i input.mp4 -t 00:00:10 -c:v libx264 output.mp4
  #   set the start time and duration as seconds
  ffmpeg -ss 40.0 -i input.mp4 -t 10.0 -c:v libx264 output.mp4
  #   skip an exact number of frames at the start (100)
  ffmpeg -i input.mp4 -vf 'select=gte(n\,100)' -c:v libx264 output.mp4

  # cut (w/o reencoding - cut times will be approximate)
  ffmpeg -ss 40.0 -i input.mp4 -t 10.0 -c copy output.mp4

  # save all keyframes to images
  ffmpeg -i video.mp4 -vf "select=eq(pict_type\,I)" -vsync vfr video-%03d.png

  # encode video from images (image numbering must be sequential)
  ffmpeg -r 25 -i image_%04d.jpg -vcodec libx264 timelapse.mp4

  # flip image horizontally
  ffmpeg -i input.mp4 -vf hflip -c:v libx264 output.mp4

  # crop and concatenate 3 videos vertically
  ffmpeg -i cam_4.mp4 -i cam_5.mp4 -i cam_6.mp4 -filter_complex "[0:v]crop=1296:432:0:200[c0];[1:v]crop=1296:432:0:200[c1];[2:v]crop=1296:432:0:230[c2];[c0][c1][c2]vstack=inputs=3[out]" -map "[out]" out.mp4

  # 2x2 mosaic (all inputs must be same size)
  ffmpeg -i video1.mp4 -i video2.mp4 -i video3.mp4 -i video4.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[row1];[2:v][3:v]hstack=inputs=2[row2];[row1][row2]vstack=inputs=2[out]" -map "[out]" out.mp4

  # picture-in-picture
  ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[1:v]scale=iw/3:ih/3[pip];[0:v][pip]overlay=main_w-overlay_w-20:main_h-overlay_h-20[out]" -map "[out]" out.mp4

  # print framerate of every file in dir
  for f in *.mp4; do echo $f; mediainfo $f|grep "Frame rate"; done

  # print selected info of every file in dir in CSV format
  for f in *.mp4; do echo -n $f,; mediainfo --Inform="Video;%Duration%,%FrameCount%,%FrameRate%" $f; done
Post reply on HN