Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • FFMPEG - colorkey [closed]

    17 mai, par Acnologla

    i am using the following command to remove chroma key:

    ffmpeg -i black.png -i video.mp4 -filter_complex '[1:v]colorkey=0x70d021:0.35:0.15[ckout];[0:v][ckout]overlay[out]' -map '[out]' video-.mp4

    but it results in these strange things around her

    original video

    Out video

  • What are all of the file extensions supported by FFmpeg

    17 mai, par zjevander

    How would I go about getting a list of all the file extensions supported by FFmpeg for use in an ExtensionFilter used by FileChooser in JavaFX?

    I am familiar with the "-codecs" and "-formats" options from FFmpeg, but these list the format and codec names which do not necessarily coincide with their file extensions.

    e.g. (partial output from "ffmpeg -formats")

    • D aac raw ADTS AAC (Advanced Audio Coding)
    • DE ac3 raw AC-3
    • E matroska Matroska

    parsing aac and ac3 from the output of ffmpeg would work fine to create file extensions for those types of files, but matroska has ".mkv" file extension.

  • Convert a bash script to Windows bat script [closed]

    17 mai, par gyandoo

    I have a bash script, now I need to convert it to bat.

    What the script does is based on the shortcut the script checks the audio codec and video codec using ffprobe and then loops through all the files in the folder to convert the file(s) using the presets based on which one the shortcut calls.

    It also limits the processor usage before running ffmpeg.

    Here's the script:

    #!/bin/sh
    FILES="/home/red/Downloads/to_convert/*"
    to_convert="/home/red/Downloads/to_convert"
    TYPE="$1"
    #echo "$TYPE"
    if [ -e '/tmp/convert.txt' ]; then
      echo "Ffmpeg is currently converting a file!"
      exit 0
    else
    if [ "$(ls -A $to_convert)" ];
    then
        #Create a temp file so if the script is run hourly and there is an existing instance running the scripts exits
        echo >> '/tmp/convert.txt'
        #iterate through each file in the directory
        for f in $FILES
        do
        FILENAME1=$(basename "$f")
        FILENAME=${FILENAME1%.*}
    
        
        ##  Detect what audio codec is being used:
        audio=$(ffprobe "$f" 2>&1 | sed -n '/Audio:/s/.*: \([a-zA-Z0-9]*\).*/\1/p' | sed 1q)
        ##  Detect video codec:
        video=$(ffprobe "$f" 2>&1 | sed -n '/Video:/s/.*: \([a-zA-Z0-9]*\).*/\1/p' | sed 1q)
        ##  Set default audio settings (you may need to use a different encoder,
        ##  since libfdk_aac is not re-distributable)
        aopts="-c:a libfdk_aac -vbr 3"
        ##  Set default video settings:
        vopts="-c:v libx264 -crf 22 -preset veryfast"
    
        case "$audio" in
            aac|mp3 )
        #If the audio is one of the MP4-supported codecs,
        #copy the stream instead of transcoding
                aopts="-c:a copy"
                ;;
            "" )
        #If there is no audio stream, don't bother with audio
                aopts="-an"
                ;;
            * )
                ;;
        esac
    
        case "$video" in
        #If the video stream is one of the MP4-compatible formats,
        #copy the stream
            h264|mpeg4|mpeg2video|mpeg1video )
                vopts="-c:v copy"
                ;;
            "" )
        #If no video stream is detected, don't bother with video
                vopts="-vn"
                ;;
            * )
                ;;
        esac
    
        
        if [ "$TYPE" = "shrink" ]; then
        
          taskset -c 0,2 ffmpeg -i "$f" -vcodec libx265 -crf 28 -map_metadata -1 "/home/red/Downloads/done/""$FILENAME"".mp4" && success=0 || success=1
    
        elif [ "$TYPE" = "phone" ]; then
    
          taskset -c 0,2 ffmpeg -y -i "$f" -vf scale=640:-2 -map_metadata -1 "/home/red/Downloads/done/""$FILENAME"".mp4" && success=0 || success=1
    
        elif [ "$TYPE" = "pmv" ]; then
    
          taskset -c 0,2 ffmpeg -y -i "$f" -vf scale=360:-2 -map_metadata -1 "/home/red/Downloads/done/""$FILENAME"".mp4" && success=0 || success=1      
    
        elif [ "$TYPE" = "music" ]; then
    
          taskset -c 0,2 ffmpeg -i "$f" -acodec libmp3lame "/home/red/Downloads/done/""$FILENAME"".mp3" && success=0 || success=1  
    
        elif [ "$TYPE" = "audio-boost" ]; then
    
          taskset -c 0,2 ffmpeg -i "$f" -vcodec copy -af "volume=10dB" "/home/red/Downloads/done/""$FILENAME"".mp4" && success=0 || success=1
    
        elif [ "$TYPE" = "burn-first-sub" ]; then  
    
          taskset -c 0,2 ffmpeg -i "$f" -vf "subtitles=""$f"":si=0'" "/home/red/Downloads/done/""$FILENAME"".mp4" && success=0 || success=1
    
        elif [ "$TYPE" = "burn-srt" ]; then  
    
          taskset -c 0,2 ffmpeg -i "$f" -vf "subtitles=/home/red/Downloads/to_convert/""$FILENAME"".srt" "/home/huckleberry/Downloads/done/""$FILENAME"".mp4" && success=0 || success=1
    
        elif [ "$TYPE" = "audio-track2" ]; then  
    
          taskset -c 0,2 ffmpeg -y -i "$f" -map 0:v -map 0:a:1 $vopts $aopts -map_metadata -1 "/home/red/Downloads/done/""$FILENAME"".mp4" && success=0 || success=1
    
        elif [ "$TYPE" = "split" ]; then  
    
          taskset -c 0,2 MP4Box -splits 1996800 "$f" && success=0 || success=1
    
        elif [ "$TYPE" = "fix" ]; then  
          taskset -c 0,2 ffmpeg -y -i "$f" -map 0:v:0 -map 0:a:0 -vcodec libx264 -acodec aac -map_metadata -1 "/home/red/Downloads/done/""$FILENAME"".mp4" && success=0 || success=1
    
        else    
    
          taskset -c 0,2 ffmpeg -y -i "$f" -map 0:v -map 0:a:0 $vopts $aopts -map_metadata -1 "/home/red/Downloads/done/""$FILENAME"".mp4" && success=0 || success=1
    
          TYPE="converted"
    
        fi
    
        
        if [ $success -eq 0 ]; then
            swaks --header Subject:"${TYPE} - ${FILENAME}" --body "${FILENAME}" -S
            echo "Removing $f file..."
            rm "$f"
        else
            swaks --header Subject:"failed - ${FILENAME}" --body "${FILENAME}" -S
            echo "process failed"
        fi    
       
        done
        
        #remove the temp file created
        rm "/tmp/convert.txt"
        exit 0
    else
        echo "to_convert folder is empty"
        exit 0
    fi
    exit 0
    fi
    
    
  • ffmpeg : Apply a time-based expr to control intensity of lowpass, highpass, aphaser, or aecho [closed]

    17 mai, par Wes Modes

    I am procedurally constructing complexFilters for ffmpeg via fluent-ffmpeg. My fluent-ffmpeg complex filters look like:

    {
       "filter": "volume",
       "options": {
           "volume": "min(1, max(0, ((cos(PI * t * 1 / 13) * 1 + cos(PI * t * 1 / 7) * 0.5 + cos(PI * t * 1 / 3) * 0.25) +
    -0.5 ) * 0.75 * -1 + 0.5))",
           "eval": "frame"
        },
        "inputs": "track_1_output",
        "outputs": "track_1_adjusted"
    },
    

    Note that I am using an expression to determine the volume dynamically.

    Here I'm testing on the command line, to understand the mysteries of lightly-documented ffmpeg filters. I'm fading in and out two sources, intertwined in the output. Now I want to apply lowpass, highpass, aphaser, and/or aecho to the transitions using a time-based expr.

    I've already succeeded using the volume filter to fade the sources in and out (Note that the sine has reversed polarity for the second volume filter):

    # working fade in/out
    ffmpeg -i knox.mp3 -i static.mp3 -filter_complex \
    "[0:a] \
        volume = 'min(1, max(0, 0.5 + 0.5 * cos(PI * t / 5)))': eval=frame \
        [a0]; \
    [1:a] \
        volume = 'min(1, max(0, 0.5 - 0.5 * cos(PI * t / 5)))': eval=frame \
        [a1]; \
    [a0][a1]
        amix = inputs=2: duration=shortest" \
    -c:a libmp3lame -q:a 2 output.mp3
    

    ffmpeg -filters says that lowpass has time-based support:

      T.. = Timeline support
     TSC lowpass           A->A       Apply a low-pass filter with 3dB point frequency.
    

    How can I similarly apply these other filters to source1 using a time-bassed expr? I was unsuccessful in figuring out lowpass and highpass:

    # applying a lowpass filter
    ffmpeg -i knox.mp3 -i static.mp3 -filter_complex \
    "[0:a] \
        volume = 'min(1, max(0, 0.5 + 0.5 * cos(PI * t / 5)))': eval=frame, \
        lowpass=f=3000: mix='0.5 + 0.5 * cos(PI * t / 5)' \
        [a0]; \
    [1:a] \
        volume = 'min(1, max(0, 0.5 - 0.5 * cos(PI * t / 5)))': eval=frame \
        [a1]; \
    [a0][a1]
        amix = inputs=2: duration=shortest" \
    -c:a libmp3lame -q:a 2 output.mp3
    

    With the resultant error:

    [Parsed_lowpass_1 @ 0x7f9a72005c00] [Eval @ 0x7ff7bec423d8] Undefined constant or missing '(' in 't/5)'
    [Parsed_lowpass_1 @ 0x7f9a72005c00] Unable to parse option value "0.5 + 0.5 * cos(PI * t / 5)"
    Error applying option 'mix' to filter 'lowpass': Invalid argument
    

    What complicated fffmpeg faerie magic is needed to make some of the filters other than volume controlled by a time-based expr?

  • LL-HLS (CMAF/fMP4) minimize latency with FFplay

    16 mai, par DanielB6

    How do I minimize latency when streaming LL-HLS (CMAF/fMP4) via FFplay?

    I configured a live video stream which is broadcast from a media server using LL-HLS. I see the following results:

    • HLS.js: ~2 seconds behind the source
    • FFplay (./ffplay "https:////playlist.m3u8"): ~8 seconds behind the source
    • FFplay (./ffplay -fflags nobuffer -flags low_delay -strict experimental "https:////playlist.m3u8"): ~5 seconds behind the source

    My goal is to achieve what HLS.js can achieve in a browser, ~2 seconds behind the source.