Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to see reference list of a slice/frame of a video using FFprobe

    28 mai 2017, par Andy

    Suppose I have a avi/mkv/mp4 video, the video has some GOP structure( IPPP/IBBP etc) which can be seen from FFprobe. But can I see reference picture list(L0 and L1), that is frames from which B is using bi-directional prediction using FFprobe?

  • FFMPEG : create movie from timestamped images

    28 mai 2017, par HyperDevil

    Im trying to make a small movie file from a folder with webcam images.

    They are named like this:
    00-00-38.jpg
    00-05-37.jpg
    00-10-37.jpg
    00-15-37.jpg

    H-M-S.jpg format

    Although i tried patterntype glob and simpler commands i cannot get it to work.

    This is what i tried:

    ffmpeg -r 1 -pattern_type glob -i '*.jpg' -scale=720:-1 -c:v libx264 out.mp4 
    (got only one image)
    ffmpeg -r 25 -i *.jpg -vf "scale=720:-1" output.mp4
    (same size as a jpg file but no video)
    

    Console output:

    ffmpeg -framerate 1 -pattern_type glob -i "*.jpg" -vf scale=720:-1 -c:v libx264 -pix_fmt yuv420p out.mp4
        ffmpeg version 1.0.10 Copyright (c) 2000-2014 the FFmpeg developers  built on Jul 25 2014 07:50:40 with gcc 4.7 (Debian 4.7.2-5)
          configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' 
        --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis 
        --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-li
        bopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --
        enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --
        enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64
        -linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enabl
        e-libopus --enable-fontconfig --enable-libfdk-aac --enable-libdc1394 --disable-altivec --dis
          libavutil      51. 73.101 / 51. 73.101
          libavcodec     54. 59.100 / 54. 59.100
          libavformat    54. 29.104 / 54. 29.104
          libavdevice    54.  2.101 / 54.  2.101
          libavfilter     3. 17.100 /  3. 17.100
          libswscale      2.  1.101 /  2.  1.101
          libswresample   0. 15.100 /  0. 15.100
          libpostproc    52.  0.100 / 52.  0.100
        [image2 @ 0x1d53f00] max_analyze_duration 5000000 reached at 5000000
        Input #0, image2, from '*.jpg':
          Duration: 00:04:48.00, start: 0.000000, bitrate: N/A
            Stream #0:0: Video: mjpeg, yuvj420p, 800x593 [SAR 96:96 DAR 800:593], 1 fps, 1 tbr, 1 tbn, 1 tbc
        [libx264 @ 0x1d35bc0] using SAR=1780/1779
        [libx264 @ 0x1d35bc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX XOP FMA4 FMA3 SSEMisalign LZCNT BMI1
        [libx264 @ 0x1d35bc0] profile High, level 2.2
        [libx264 @ 0x1d35bc0] 264 - core 132 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options:  ca
        bac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dc
        t=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=
        0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 key
        int_min=1 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=
        1:1.00
        Output #0, mp4, to 'out.mp4':
          Metadata:
            encoder         : Lavf54.29.104
            Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 720x534 [SAR 1780:1779 DAR 800:593], q=-1--1, 1 tbn, 1 tbc
        Stream mapping:
          Stream #0:0 -> #0:0 (mjpeg -> libx264)
        Press [q] to stop, [?] for help
        frame=  288 fps=145 q=32763.0 Lsize=     349kB time=00:04:46.00 bitrate=  10.0kbits/s
        video:345kB audio:0kB subtitle:0 global headers:0kB muxing overhead 1.208469%
        [libx264 @ 0x1d35bc0] frame I:2     Avg QP: 2.80  size:130328
        [libx264 @ 0x1d35bc0] frame P:73    Avg QP: 4.70  size:  1167
        [libx264 @ 0x1d35bc0] frame B:213   Avg QP:17.33  size:    30
        [libx264 @ 0x1d35bc0] consecutive B-frames:  1.4%  0.0%  0.0% 98.6%
        [libx264 @ 0x1d35bc0] mb I  I16..4: 20.2% 24.9% 55.0%
        [libx264 @ 0x1d35bc0] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  4.3%  0.1%  0.2%  0.0%  0.0%    skip:95.5%
        [libx264 @ 0x1d35bc0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.8%  0.0%  0.0%  direct: 0.0%  skip:99.2%  L0: 5.4% L1:94.5% BI: 0.0
        %
        [libx264 @ 0x1d35bc0] 8x8 transform intra:24.9% inter:51.5%
        [libx264 @ 0x1d35bc0] coded y,uvDC,uvAC intra: 99.4% 0.0% 0.0% inter: 0.6% 0.0% 0.0%
        [libx264 @ 0x1d35bc0] i16 v,h,dc,p:  5% 19% 52% 25%
        [libx264 @ 0x1d35bc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 28% 21%  4%  6%  4%  8%  5% 15%
        [libx264 @ 0x1d35bc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 27% 13%  6%  8%  5%  9%  6% 12%
        [libx264 @ 0x1d35bc0] i8c dc,h,v,p: 100%  0%  0%  0%
        [libx264 @ 0x1d35bc0] Weighted P-Frames: Y:0.0% UV:0.0%
        [libx264 @ 0x1d35bc0] ref P L0: 98.1%  0.0%  1.7%  0.2%
        [libx264 @ 0x1d35bc0] ref B L0: 52.0% 48.0%
        [libx264 @ 0x1d35bc0] ref B L1: 73.0% 27.0%
        [libx264 @ 0x1d35bc0] kb/s:9.78
    

    The video is 364KB without any video.

  • FFMPEG concat causing audio glitches in segments boundaries

    28 mai 2017, par Idan

    I am segmenting a video file to 10sec segments, transcoding each of them and then run a concat to merge them all back together. While the whole process works without errors and the final file is valid and playable, I've noticed some sort of glitches/interruptions in the audio stream when passing over the original segments boundaries.

    For example, in a 60sec video that was segmented to 10sec segments and stitched back again, the final output will show audio interruptions in 10/20/30/40/50 sec timestamps.

    For segmenting the files I use:

    ffmpeg -y -i $INPUT_FILE -c copy -flags -global_header -segment_time 10 -break_non_keyframes 0 -reset_timestamps 1 -segment_list file_segs.list -segment_list_type ffconcat -write_empty_segments 0 -segment_format mp4  -f segment file_seg-%d.mp4
    

    And for concat I use:

    ffmpeg -y -f concat -i file_segs.list -c copy -movflags +faststart file_video.mp4
    

    Transcoding is to libx264 / aac

    What might be the cause? Is there any way to work around this problem?

  • Restart ffmpeg process using monit if TOTAL CPU is less than 1%

    28 mai 2017, par user2201239

    I have used kind of similar solution like this Restarting ffmpeg process using monit to restart my ffmpeg stream in case it fails for some reason. Remember its not duplicate problem/question, because I have other issues unlike the example question/solution Restarting ffmpeg process using monit, which I'm gonna explain below. So here is my monit configuration:

        check process FFMPEGStream with pidfile PATH-to-file/streampid.pid
        start program = "PATH-to-file/streambash.sh restart"
        stop program = "PATH-to-file/streambash.sh stop"
        if TOTAL CPU is less than 1% for 10 cycles then restart
    

    Here is my streambash.sh file:

        #!/bin/bash
        pid_file="PATH-to-file/streampid.pid"
    
        case "$1" in
         restart)
            PATH-to-file/streambash.sh stop
            PATH-to-file/streambash.sh start
               ;;
    
         start)
            rm $pid_file
            /usr/bin/ffmpeg -i "INPUT-PATH" -c:v libx264 -b:v 900k -preset ultrafast -aspect 16:9 -s 640x376 -strict experimental -c:a aac -b:a 96k -f flv "RTMP-PATH" &> /dev/null &
            ch_pid=$! 
            echo "Start Stream1: ffmpeg = $ch_pid";
            echo $ch_pid > $pid_file
               ;;
    
         stop)
            echo "Stop ffmpeg Stream1";
            kill `cat $pid_file` &> /dev/null
               ;;
    
         *)
            echo "Usage: PATH-to-file/streambash.sh {start|stop|restart}"
            exit 1
               ;;
    
         esac
        exit 0
        echo $pid_file
    

    Monit can start the bash file successfully, but when this condition "if TOTAL CPU is less than 1% for 10 cycles then restart" is matched in monit configuration, it tries to restart, it gives error that process is not running. But in actual the ffmpeg process still runs in the background and I can see that the stream is live on my website. Here is monit logs:

        [CET Jan 10 12:55:02] error    : 'FFMPEGStream' total cpu usage of 0.4% matches resource limit [cpu usage>1.0%]
        [CET Jan 10 12:55:07] error    : 'FFMPEGStream' total cpu usage of 0.0% matches resource limit [cpu usage>1.0%]
        [CET Jan 10 12:55:12] error    : 'FFMPEGStream' total cpu usage of 0.0% matches resource limit [cpu usage>1.0%]
        [CET Jan 10 12:55:17] error    : 'FFMPEGStream' total cpu usage of 0.4% matches resource limit [cpu usage>1.0%]
        [CET Jan 10 12:55:22] error    : 'FFMPEGStream' total cpu usage of 0.9% matches resource limit [cpu usage>1.0%]
        [CET Jan 10 12:55:27] error    : 'FFMPEGStream' total cpu usage of 0.9% matches resource limit [cpu usage>1.0%]
        [CET Jan 10 12:55:32] error    : 'FFMPEGStream' total cpu usage of 0.0% matches resource limit [cpu usage>1.0%]
        [CET Jan 10 12:55:37] error    : 'FFMPEGStream' total cpu usage of 0.0% matches resource limit [cpu usage>1.0%]
        [CET Jan 10 12:55:42] error    : 'FFMPEGStream' total cpu usage of 0.0% matches resource limit [cpu usage>1.0%]
        [CET Jan 10 12:55:47] error    : 'FFMPEGStream' total cpu usage of 0.4% matches resource limit [cpu usage>1.0%]
        [CET Jan 10 12:55:50] info     : 'FFMPEGStream' trying to restart
        [CET Jan 10 12:55:50] info     : 'FFMPEGStream' stop: PATH-to-file/streambash.sh
        [CET Jan 10 12:55:51] info     : 'FFMPEGStream' start: PATH-to-file/streambash.sh
        [CET Jan 10 12:55:56] error    : 'FFMPEGStream' process is not running
        [CET Jan 10 12:55:58] info     : 'FFMPEGStream' trying to restart
        [CET Jan 10 12:55:58] info     : 'FFMPEGStream' start: PATH-to-file/streambash.sh
        [CET Jan 10 12:56:04] error    : 'FFMPEGStream' process is not running
        [CET Jan 10 12:56:04] info     : 'FFMPEGStream' trying to restart
        [CET Jan 10 12:56:04] info     : 'FFMPEGStream' start: PATH-to-file/streambash.sh
        [CET Jan 10 12:56:09] error    : 'FFMPEGStream' process is not running
        [CET Jan 10 12:56:09] info     : 'FFMPEGStream' trying to restart
        [CET Jan 10 12:56:09] info     : 'FFMPEGStream' start: PATH-to-file/streambash.sh
    

    Monit keeps trying to restart the process and on each retry, it dumps a new pid to the PATH-to-file/streampid.pid, but as I said it seems, it somehow can stop the actual ffmpeg stream/pid, which keep running in the background.

  • Ffmpeg subtitle use all available frame

    28 mai 2017, par Sulli

    I am using ffmpeg to generate subtitles on a small black frame I want to later embed in a bigger video:

    ffmpeg -t 184 -s 1920x420 -f rawvideo -pix_fmt rgb24 -r 25 -i /dev/zero empty.mp4
    ffmpeg -i empty.mp4 -pix_fmt yuv420p -c:a copy -vf subtitles=captions.fr_FR.srt:force_style='FontName=eras-bold-itc.ttf' out.mp4
    

    The problem is, ffmpeg prints the subtitles in small at the bottom of empty.mp4, as it would do for a normal video.

    Is there any way to tell ffmpeg to use the full clip area (1920x420) to print the subtitles?

    If no, is there any way to specify the size of the bottom part of a regular video where the subtitles should stay (for instance, stay within 400 pixels from the bottom)?