Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Hide or show overlay with sendcmd

    28 janvier 2019, par Сергей Сергеев

    Sendcmd in ffmpeg

    Can I hide the overlay and then show it with sendcmd?

  • Sendcmd in ffmpeg

    28 janvier 2019, par Makes

    Why sendcmd in ffmpeg works with drawtext, but does not work with scale, rotation and other filters?

    Example (this code works)

    ffmpeg  -i testIN.mp4 -filter_complex "[0:v]sendcmd=f=testTXT.cmd,drawtext=fontfile=PF.ttf:text='': fontcolor=white:fontsize=150" testOUT.mp4
    

    testTXT.cmd

    0 drawtext reinit 'text=111';
    1 drawtext reinit 'text=222';
    2 drawtext reinit 'text=333';
    

    Example (this code does not work)

    ffmpeg -i testIN.mp4 -filter_complex "[0:v]sendcmd=f=testTXT.cmd,drawbox=x=10:y=10:w=100:h=100" testOUT.mp4
    

    testTXT.cmd

    0 drawbox reinit 'x=20:y=20:w=200:h=200';
    1 drawbox reinit 'x=30:y=30:w=300:h=300';
    2 drawbox reinit 'x=40:y=40:w=400:h=400';
    
  • Serving live stream by using ffmpeg via rtmp protocol

    28 janvier 2019, par Yusufu

    I have been trying to serve my rtmp stream to web, struggling with videojs I am able to serve my static video or live stream from android screen by using ffmpeg via this command:

    ffmpeg -i video7.mp4 -c:v libx264 -g 25 -preset fast -b:v 4096k -c:a libfdk_aac -ar 44100 -f flv rtmp://127.0.0.1/media_server/video.flv

    So can connect it via ffplay. This part works like a charm.

    ffplay  rtmp://127.0.0.1/media_server/video.flv
    

    But couldnt watch in web. My html file here. Copied from videojs offical example

    1. question : Being able to watch via ffplay on rtmp means my nginx rtmp module works well ?
    2. I have been serving httml via http-server and rtmp on rtmp://127.0.0.1 without port caused problem ?

    3. Any other videoplayer advice ? I have already tried hls it works but in my case creating m3u8 manifest file not desired because I am streaming live video from mobile screen record so creating new ts files nut not updated m3u8 file not for me I guess ?

    4. What else I can try as a protocol ? instead of rtmp

    I can share about my screenrecord and ffmpeg commands to help me or you. Thanks

  • Concatenating slideshows and normal videos causes audio bleeding

    28 janvier 2019, par Zurechtweiser

    I noticed audio bleeding with concatenated videos containing alternating slideshows and normal videos.

    My commands

    ffmpeg -y -ss 00:00:04.391 -to 00:02:17.171 -i "test.MP4" -r 60 -c:v libx264 -af afade=t=in:ss=0:d=1,afade=t=out:st='00\:02\:11.780':d=1 25.mp4
    ffmpeg -y -i 25.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts 25f.ts
    
    ffmpeg -y -loop 1 -i "test.JPG" -t 2 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -shortest -r 60 -c:v libx264 -c:a aac -pix_fmt yuv420p -vf scale=-2:1080,pad=width=1920:height=1080:x=240:y=0:color=black 26.mp4
    ffmpeg -y -i 26.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts 26f.ts
    
    ffmpeg -y -i "concat:25f.ts|26f.ts" -bsf:a aac_adtstoasc -movflags faststart -c copy "final.mp4"
    

    The rest of audio of test.MP4 bleeds into the beginning of the test.JPG-single frame slideshow.

    I presumed a different framerate to cause it, but adding -r 60 didn't solve the issue.

    Also it seems that the video player interpretes the final video as a set of single videos, as whenever a "new" video shows up, it stutters slightly and loses framerate.

    How do I concat them without bleeding and create a final video without stuttering?

    ffprobe -show_streams 25.mp4:

    ffprobe version N-92246-gc2ac3b8e6a Copyright (c) 2007-2018 the FFmpeg developers
      built with gcc 8.2.1 (GCC) 20181017
      configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
      libavutil      56. 19.101 / 56. 19.101
      libavcodec     58. 33.102 / 58. 33.102
      libavformat    58. 19.102 / 58. 19.102
      libavdevice    58.  4.106 / 58.  4.106
      libavfilter     7. 37.100 /  7. 37.100
      libswscale      5.  2.100 /  5.  2.100
      libswresample   3.  2.100 /  3.  2.100
      libpostproc    55.  2.100 / 55.  2.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '25.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf58.19.102
      Duration: 00:00:12.65, start: 0.000000, bitrate: 2040 kb/s
        Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1215:1216 DAR 135:76], 1903 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
        Metadata:
          handler_name    : VideoHandle
        Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
        Metadata:
          handler_name    : SoundHandle
    [STREAM]
    index=0
    codec_name=h264
    codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
    profile=High
    codec_type=video
    codec_time_base=1/120
    codec_tag_string=avc1
    codec_tag=0x31637661
    width=1920
    height=1080
    coded_width=1920
    coded_height=1088
    has_b_frames=2
    sample_aspect_ratio=1215:1216
    display_aspect_ratio=135:76
    pix_fmt=yuv420p
    level=42
    color_range=unknown
    color_space=unknown
    color_transfer=unknown
    color_primaries=unknown
    chroma_location=left
    field_order=unknown
    timecode=N/A
    refs=1
    is_avc=true
    nal_length_size=4
    id=N/A
    r_frame_rate=60/1
    avg_frame_rate=60/1
    time_base=1/15360
    start_pts=0
    start_time=0.000000
    duration_ts=193792
    duration=12.616667
    bit_rate=1903528
    max_bit_rate=N/A
    bits_per_raw_sample=8
    nb_frames=757
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=1
    DISPOSITION:dub=0
    DISPOSITION:original=0
    DISPOSITION:comment=0
    DISPOSITION:lyrics=0
    DISPOSITION:karaoke=0
    DISPOSITION:forced=0
    DISPOSITION:hearing_impaired=0
    DISPOSITION:visual_impaired=0
    DISPOSITION:clean_effects=0
    DISPOSITION:attached_pic=0
    DISPOSITION:timed_thumbnails=0
    TAG:language=eng
    TAG:handler_name=VideoHandle
    [/STREAM]
    [STREAM]
    index=1
    codec_name=aac
    codec_long_name=AAC (Advanced Audio Coding)
    profile=LC
    codec_type=audio
    codec_time_base=1/48000
    codec_tag_string=mp4a
    codec_tag=0x6134706d
    sample_fmt=fltp
    sample_rate=48000
    channels=2
    channel_layout=stereo
    bits_per_sample=0
    id=N/A
    r_frame_rate=0/0
    avg_frame_rate=0/0
    time_base=1/48000
    start_pts=0
    start_time=0.000000
    duration_ts=606192
    duration=12.629000
    bit_rate=128049
    max_bit_rate=128049
    bits_per_raw_sample=N/A
    nb_frames=593
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=1
    DISPOSITION:dub=0
    DISPOSITION:original=0
    DISPOSITION:comment=0
    DISPOSITION:lyrics=0
    DISPOSITION:karaoke=0
    DISPOSITION:forced=0
    DISPOSITION:hearing_impaired=0
    DISPOSITION:visual_impaired=0
    DISPOSITION:clean_effects=0
    DISPOSITION:attached_pic=0
    DISPOSITION:timed_thumbnails=0
    TAG:language=eng
    TAG:handler_name=SoundHandle
    [/STREAM]
    

    ffprobe -show_streams 26.mp4:

    ffprobe version N-92246-gc2ac3b8e6a Copyright (c) 2007-2018 the FFmpeg developers
      built with gcc 8.2.1 (GCC) 20181017
      configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
      libavutil      56. 19.101 / 56. 19.101
      libavcodec     58. 33.102 / 58. 33.102
      libavformat    58. 19.102 / 58. 19.102
      libavdevice    58.  4.106 / 58.  4.106
      libavfilter     7. 37.100 /  7. 37.100
      libswscale      5.  2.100 /  5.  2.100
      libswresample   3.  2.100 /  3.  2.100
      libpostproc    55.  2.100 / 55.  2.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '26.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf58.19.102
      Duration: 00:00:03.95, start: 0.000000, bitrate: 1814 kb/s
        Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 2272x4608 [SAR 1:1 DAR 71:144], 1798 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
    [STREAM]
    index=0
    codec_name=h264
    codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
    profile=High
    codec_type=video
    codec_time_base=1/120
    codec_tag_string=avc1
    codec_tag=0x31637661
    width=2272
    height=4608
    coded_width=2272
    coded_height=4608
    has_b_frames=2
    sample_aspect_ratio=1:1
    display_aspect_ratio=71:144
    pix_fmt=yuv420p
    level=60
    color_range=unknown
    color_space=unknown
    color_transfer=unknown
    color_primaries=unknown
    chroma_location=left
    field_order=unknown
    timecode=N/A
    refs=1
    is_avc=true
    nal_length_size=4
    id=N/A
    r_frame_rate=60/1
    avg_frame_rate=60/1
    time_base=1/15360
    start_pts=0
    start_time=0.000000
    duration_ts=60672
    duration=3.950000
    bit_rate=1798815
    max_bit_rate=N/A
    bits_per_raw_sample=8
    nb_frames=237
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=1
    DISPOSITION:dub=0
    DISPOSITION:original=0
    DISPOSITION:comment=0
    DISPOSITION:lyrics=0
    DISPOSITION:karaoke=0
    DISPOSITION:forced=0
    DISPOSITION:hearing_impaired=0
    DISPOSITION:visual_impaired=0
    DISPOSITION:clean_effects=0
    DISPOSITION:attached_pic=0
    DISPOSITION:timed_thumbnails=0
    TAG:language=und
    TAG:handler_name=VideoHandler
    [/STREAM]
    [STREAM]
    index=1
    codec_name=aac
    codec_long_name=AAC (Advanced Audio Coding)
    profile=LC
    codec_type=audio
    codec_time_base=1/44100
    codec_tag_string=mp4a
    codec_tag=0x6134706d
    sample_fmt=fltp
    sample_rate=44100
    channels=2
    channel_layout=stereo
    bits_per_sample=0
    id=N/A
    r_frame_rate=0/0
    avg_frame_rate=0/0
    time_base=1/44100
    start_pts=0
    start_time=0.000000
    duration_ts=132300
    duration=3.000000
    bit_rate=2124
    max_bit_rate=128000
    bits_per_raw_sample=N/A
    nb_frames=131
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=1
    DISPOSITION:dub=0
    DISPOSITION:original=0
    DISPOSITION:comment=0
    DISPOSITION:lyrics=0
    DISPOSITION:karaoke=0
    DISPOSITION:forced=0
    DISPOSITION:hearing_impaired=0
    DISPOSITION:visual_impaired=0
    DISPOSITION:clean_effects=0
    DISPOSITION:attached_pic=0
    DISPOSITION:timed_thumbnails=0
    TAG:language=und
    TAG:handler_name=SoundHandler
    [/STREAM]
    
  • Output FFMPEG segments to GCS

    28 janvier 2019, par Terrabyte

    Im trying to output an ffmpeg hls stream to google cloud storage after each segment is created or at least after the entire encoding is done. Doesn anyone know how to accomplish this?

    This is what i have in my bash script:

    $FFMPEG -hide_banner -i "$infile" \
        $PASSVAR \
        -y \
        -codec:v "$VIDEO_CODEC" \
        -codec:a "$AUDIO_CODEC" \
        -threads "$NUMTHREADS" \
        -map 0:v \
        -map 0:a \
        -flags \
        -global_header \
        -f segment \
        -segment_list "$playlist_name" \
        -segment_time "$SEGLENGTH" \
        -segment_format mpeg_ts \
        -g "$key_frames_interval" \
        -keyint_min "$key_frames_interval" \
        $resolution \
        $bitrate \
        $FFMPEG_ADDITIONAL \
        $FFMPEG_FLAGS \
        "$OUTPUT_DIRECTORY/$output_name" | gsutil -m mv "$OUTPUT_DIRECTORY/$output_name" gs://bucket-vod-example
    }
    

    does anyone know how to output the files to gsutls as it's being encoded? I can make the output the mounted storage point of google cloud storage but encoding directly to it is extremely slow so if possible is there way to encode locally then transfer as it's being encoded?