Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • In Command Line, how do I use a constant set by a nested For ?

    20 octobre 2016, par Neo Herakles

    Is it possible to set a variable through a For and then use its value? I'm using two For, one to move across a whole folder and the other one to get the value I desire, the issue here is, the operation done by %watermark% doesn't recognize the value of %duration%, I believe it's trying the set the constant and then do the operation simultaneously and that's why there's no value, could you please tell me how to pass the variable's value to duration?

    @echo off
    setlocal
    for %%G in ("%~dp0\water\*.mp4") do (
        for /F "delims=" %%I in ('ffprobe.exe -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 %%I 2^>^&1') do (
        set "duration=%%I"
        ffmpeg.exe -i "%%G" -i Watermark.png -filter_complex "[0:v]scale=iw:ih[v0];[1:v][v0]scale2ref=iw/6:ih/10[logo][0v];[0v][logo]overlay=W-w-3:H-h-3:enable='between(t,%duration%/3,(%duration%/3)+2)'[v]" -map "[v]" -map 0:a -codec:v libx264 -preset ultrafast -crf 23 -codec:a copy "%~dp0\out\%%~nG.mp4"
        )
    )
    endlocal
    pause
    

    The output for this is Undefined constant or missing '(' in '/3)+2)so it's definetely the constant the issue here. Thanks for the help.

    Edit: SOLVED, the solution was to use %%I instead of %duration%

  • Muxing two video streams without transcoding with ffpmeg and making vlc overlay them during play

    20 octobre 2016, par Laars Camot

    There is a software that claims it can be done but it's two expensive for me for a try. Basically it muxes two video streams in one and makes the second transparent video stream overlay on top of the first like it would be a subtitle stream without video filters. The software author states that the resulting output should be playable with all players, including VLC. I've tried this:

    ffmpeg -i first.ts -i second.ts -vcodec copy -acodec copy -map 0 -map 1:0 -f mpegts out.ts
    

    But it simply adds a second video stream to the resulting file. Playing it with VLC makes the player open two separate VLC instances.. no overlay at all. Is there a way to make VLC show two separate videos concurrently in the same window?

  • Combine MPEG-DASH segments (ex, init.mp4 + segments.m4s) back to a full source.mp4 ?

    20 octobre 2016, par Drake

    GPAC, http://gpac.wp.mines-telecom.fr/, can be used to do video segmentation along with MPEG-DASH spec. One type of results is a combination of init files (ex, init.mp4) and several roughly fixed-duration segments (ex, segment-%d.m4s). What if I just got those results and I like to reverse/combine them back to one full source.mp4 file? Can I use GPAC or ffmpeg for this?

  • How to use ffmpeg stream copy to make an accurate cut of a video ?

    20 octobre 2016, par wowofbob

    When I run the command below

    ffmpeg -ss start -i input_video -t duration output_video
    

    I get an accurate cut, starting from start with duration duration. Both input_video and output_video have the same format. But it's slow because of re-encoding.

    On the other hand, when I run

    ffmpeg -ss start -i input_video -t duration -c copy output_video
    

    I get a video of wrong size. Say, if start = 10 and duration = 4 then the length of video is 7.

    Also, some people suggests to put -ss parameter after -i. But it yields a damaged video.


    Is there a way to make an accurate cut of a video using stream copy, or should re-encoding be used?

  • concatenate encrypted m3u8 ts video segments into a whole

    20 octobre 2016, par iMath

    The m3u8 content

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-ALLOW-CACHE:YES
    #EXT-X-TARGETDURATION:5
    #EXT-X-MEDIA-SEQUENCE:0
    #EXT-X-KEY:METHOD=AES-128,URI="http://www.gaiamount.com/keys/3958/4k",IV=0x440796ac5ac10cc577f9bec05cd042ef
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0000.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0001.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0002.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0003.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0004.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0005.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0006.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0007.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0008.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0009.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0010.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0011.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0012.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0013.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0014.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0015.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0016.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0017.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0018.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0019.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0020.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0021.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0022.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0023.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0024.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0025.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0026.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0027.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0028.ts
    #EXTINF:5.000000,
    /seg/u116/v810_mp4_0029.ts
    #EXTINF:4.760000,
    /seg/u116/v810_mp4_0030.ts
    #EXT-X-ENDLIST
    

    I've already download all the ts video segments using another Downloader , then try to follow the method to concatenate these ts video segments into a whole , however the ffmpeg complains the following

    C:\Users\i>ffmpeg -f concat -i mylist.txt -c copy output.ts
    ffmpeg version N-81475-gdc7e5ad Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 5.4.0 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dx
    va2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-lib
    ebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --ena
    ble-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfree
    type --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enab
    le-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-lib
    openh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschr
    oedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheor
    a --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvo
    rbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --ena
    ble-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --e
    nable-decklink --enable-zlib
      libavutil      55. 29.100 / 55. 29.100
      libavcodec     57. 54.100 / 57. 54.100
      libavformat    57. 48.100 / 57. 48.100
      libavdevice    57.  0.102 / 57.  0.102
      libavfilter     6. 57.100 /  6. 57.100
      libswscale      4.  1.100 /  4.  1.100
      libswresample   2.  1.100 /  2.  1.100
      libpostproc    54.  0.100 / 54.  0.100
    [concat @ 03e30fe0] Impossible to open 'C:/Users/i/AppData/Roaming/iMath/01.ts'
    mylist.txt: Invalid data found when processing input
    
    C:\Users\i>
    

    so (1)what should I do to concatenate these encrypted m3u8 ts video segments into a whole ? (2) Any way to get the video byte size an m3u8 url referenced to ?