Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to get video duration in seconds ? [duplicate]

    14 août 2018, par user2783132

    This question already has an answer here:

    How can I get video duration in seconds?

    what I've tried:

    ffmpeg -i file.flv 2>&1 | grep "Duration"
      Duration: 00:39:43.08, start: 0.040000, bitrate: 386 kb/s
    
    
    mediainfo file.flv | grep Duration
    Duration : 39mn 43s
    

    this what close, but it's not so accurate, 2383 is 39.71 minutes

        ffmpeg -i file.flv 2>&1 | grep "Duration"| cut -d ' ' -f 4 | sed s/,// | sed 's@\..*@@g' | awk '{ split($1, A, ":"); split(A[3], B, "."); print 3600*A[1] + 60*A[2] + B[1] }'
    2383
    
  • FFMpeg slide text from right to left an leave from left to right after x seconds

    13 août 2018, par Marco van 't Klooster

    I'm trying to slide a text inside my video from right to left and leaving the video after 13 seconds. The text has to stay there for 13 seconds and the leave in the opposite direction the video.

    Right now I'm using the following command: ffmpeg -i Pool\ scores.m4v -vf "[in]drawtext=fontfile=/usr/share/fonts/truetype/msttcorefonts/Arial.ttf:fontsize=40:fontcolor=white:x=900:y=570:text='Marco':enable='between(t,11,24)' [out]" -c:v libx264 scrolling.m4v

    So the text Marco have to be at x=900 and y=570. Thats also the coordinate where the text have to leave from.

    The idea is to create a pool score board where the video is auto generated with dynamic text. In this image there is an example of what the animation have to look like. I've to retime it tom match the same speed. See example

    Thanks in advance!!

  • Apache protected HLS stream, weird behaviour

    13 août 2018, par Gotschi

    I have 2 webcam streams published (restreamed from local LAN) via https and apache to the web.

    in my vhost file I have following setting:

    
    AuthName "Member Only"
    AuthType Basic
    AuthUserFile /var/www/.htpasswd
    require valid-user
    
    

    When I start the stream via vlc it works fine, VLC and others (Browsers) request the user and password from the user and streaming starts. And it plays fine for infinite time!

    vlc -I dummy http://192.168.178.21:8080/ vlc://quit --sout='#std{access=livehttp{seglen=10,delsegs=true,numsegs=5,index=/var/www/https/webcam/dach/stream1.m3u8,index-url='"stream1-########.ts"'},mux=ts{use-key-frames},dst=/var/www/https/webcam/dach/stream1-########.ts}'
    

    When I start it with avconv/ffmpeg:

    avconv -re -i http://192.168.178.21:8080 -c copy -flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10 -g 24 /var/www/https/webcam/dach/stream1.m3u8
    

    VLC and Browsers request the Password and it plays for a few seconds. but then after the first segments and the player requests the new .m3u8 it fails with

    401:Unauthorized

    When i turn off authentication it works fine again with avconv, so I guess this has something to do with apache?

    Here's the generated m3u8 by VLC:

    #EXTM3U
    #EXT-X-TARGETDURATION:10
    #EXT-X-VERSION:3
    #EXT-X-ALLOW-CACHE:NO
    #EXT-X-MEDIA-SEQUENCE:5
    #EXTINF:10.00,
    stream1-00000005.ts
    #EXTINF:10.00,
    stream1-00000006.ts
    #EXTINF:10.00,
    stream1-00000007.ts
    #EXTINF:10.00,
    stream1-00000008.ts
    #EXTINF:10.00,
    stream1-00000009.ts
    

    and the one by avconv:

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-TARGETDURATION:10
    #EXT-X-MEDIA-SEQUENCE:5
    #EXTINF:10,
    stream15.ts
    #EXTINF:10,
    stream16.ts
    #EXTINF:10,
    stream17.ts
    #EXTINF:10,
    stream18.ts
    #EXTINF:10,
    stream19.ts
    #EXTINF:10,
    stream10.ts
    

    Can somebody give me a hint? I need to use avconv since it allows me to map the video stream before the audio stream (video needs to be 0 and Webcam stream is often mixed up)

    thanks

  • ffmpeg_concat is not running from shell_exec() function ?

    13 août 2018, par ahmadlatif1084

    command is running on CLI on Linux.

    ffmpeg-concat -t circleopen -d 750 -o /var/www/html/testing_video/huzzah.mp4 /var/www/html/testing_video/1.mp4 /var/www/html/testing_video/2.mp4 /var/www/html/testing_video/3.mp4 2>&1

    Perfectly working on CLI. But when i used with the shell_exec command from a php file it gives an error.

    failed to create OpenGL context at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/context.js:24:11) at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/render-frames.js:19:21) at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/index.js:53:32) at

    Anyhow i debug the code function is calling and the parameters width and height is passing but still returning null.

    Node version:v8.11.3

  • FFMPEG : Set Opacity of audio waveform color

    13 août 2018, par Software Development Consultan

    I was trying to do transparency in waveform generated. It seems there is not direct option in 'showwaves' filter so I came across 'colorkey' which might help.

    I am trying with following:

    ffmpeg -y -loop 1 -threads 0 -i background.png -i input.mp3 -filter_complex "[1:a]aformat=channel_layouts=mono,showwaves=s=1280x100:rate=7:mode=cline:scale=sqrt:colors=0x0000ff,colorkey=color=0x0000ff:similarity=0.01:blend=0.1[v]; [0:v][v] overlay=0:155 [v1]" -map "[v1]" -map 1:a -c:v libx264 -crf 35 -ss 0 -t 5 -c:a copy -shortest -pix_fmt yuv420p -threads 0 test_org.mp4

    So I wanted to blue color waveform and wanted to set opacity of that 1 to 0 let say. But it seems this generates blackbox which is actual background of '1280x100'. I want to keep background of waveform transparent and just wanted to change opacity of waveform only.

    Result of my command: enter image description here

    enter image description here

    Can you please let me know your suggestion

    @Gyan, this is with reference to following question which you have answered.

    Related last question

    Thanks, Hardik