Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • zbar not working on netcat video stream from raspberry pi read using OpenCV

    26 décembre 2017, par Snehil Vijay

    I am streaming video feed from raspberry pi using netcam to my PC and using zbar to read qr codes i the feed. I am reading the named pipe using ffmpeg:

    FFMPEG_BIN = "ffmpeg"
    command = [ FFMPEG_BIN,
        '-i', 'fifo264',             # fifo is the named pipe
        '-pix_fmt', 'gray',      # opencv requires bgr24 pixel format.
        '-vcodec', 'rawvideo',
        '-an','-sn',              # we want to disable audio processing (there is no audio)
        '-f', 'image2pipe', '-']    
    pipe = sp.Popen(command, stdout = sp.PIPE, bufsize=10**8)
    

    zbar is showing no output in this case. Complete code:

    import cv2
    import subprocess as sp
    import numpy
    import zbar
    from PIL import Image
    
    
    FFMPEG_BIN = "ffmpeg"
    command = [ FFMPEG_BIN,
            '-i', 'fifo264',             # fifo is the named pipe
            '-pix_fmt', 'gray',      # opencv requires bgr24 pixel format.
            '-vcodec', 'rawvideo',
            '-an','-sn',              # we want to disable audio processing (there is no audio)
            '-f', 'image2pipe', '-']    
    pipe = sp.Popen(command, stdout = sp.PIPE, bufsize=10**8)
    
    while True:
        # Capture frame-by-frame
        raw_image = pipe.stdout.read(1920*1088)
        # transform the byte read into a numpy array
        image =  numpy.fromstring(raw_image, dtype='uint8')
        image = image.reshape((1088,1920))          # Notice how height is specified first and then width
        if image is not None:
            cv2.imshow('Video', image)
            image = Image.fromarray(image)
            width, height = image.size
            zbar_image = zbar.Image(width, height, 'Y800', image.tostring())
    
            # Scans the zbar image.
            scanner = zbar.ImageScanner()
            scanner.scan(zbar_image)
    
            # Prints data from image.
            for decoded in zbar_image:
                print(decoded.data)
    
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
        pipe.stdout.flush()
    
    cv2.destroyAllWindows()
    
  • ffmpeg annotation not working

    26 décembre 2017, par ayyanar pms

    Im using ffmpeg in php to annotate text in video,

    using binaries,

       ffmpeg.exe
       ffplay.exe
       ffprobe.exe
    

    im using like this,

    $ip = dirname(__FILE__)."/input.mp4";
    $font = dirname(__FILE__)."/arial.ttf";
    $op = dirname(__FILE__)."/output.mp4";
    $text = "stack overflow";
    
    $process = exec("ffmpeg -i $ip -vf drawtext='$font': \text=$text: fontcolor=white: fontsize=24: box=1: boxcolor=black@0.5: \boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2 -codec:a copy $op");
    

    This is not working, when i use same in cmd its working, whether its path issue ? please guide me.

  • Nginx rtmp exec_push

    26 décembre 2017, par Akim Benchiha

    I have 2 nginx instances and 1 node server with each running on separate VM. The first instance get the rtmp stream. The second instance is the HLS app. The node server execute the ffmpeg script and send the combined stream to instance 2.

    What I want is to execute ffmpeg with exec_push from instance 1 on the node server. I tried curl but it's not enough because he just receives the response.

    Nginx config :

    rtmp {
      server {
         listen 1935;
         ping 30s;
         notify_method get;
    
            application ingest {
                 live on;
                 exec_kill_signal term;
                 idle_streams off;
                 exec_push curl -s IP:3000/$name ;
                 #exec_push /usr/local/bin/ffmpeg_push.sh $name ;
               }
      }
    }
    

    NodeJS

    app.get('/:name', (req, res) =>{
    
            const testscript = exec('sh /usr/local/bin/ffmpeg_push.sh '+ req.params.name);
            testscript.stdout.on('data', function(data){
                     console.log('\x1b[32m', data);
                    // sendBackInfo();
            });
    
            testscript.stderr.on('data', function(data){
                    console.log("\x1b[31m", data);
                    // triggerErrorStuff();
            });
    
            testscript.on('close', function (code){
                    console.log("\x1b[31m", {data: {status: 'error', code: code}});
            });
    })
    
    app.listen(3000, '0.0.0.0', () => console.log("\x1b[32m", 'ok on port 3000'))
    

    Do you have any hint or idea please ? Thank you

  • file input from http (url) in melt plugin

    26 décembre 2017, par Anuj TBE

    I'm using MELT plugin for generating crossfade animation using series of images.

    I found the corssfade animation script from here.

    and the script is

    melt -verbose \
    -profile atsc_720p_25 \
    001.png out=50 \
    002.png out=75 -mix 25 -mixer luma \
    003.png out=75 -mix 25 -mixer luma \
    004.png out=75 -mix 25 -mixer luma \
    005.png out=75 -mix 25 -mixer luma \
    -consumer avformat:output.mp4 vcodec=libx264 an=1
    

    But instead of providing file from local path, I want to use http url like

    melt -verbose \
    -profile atsc_720p_25 \
    http://example.com/image1.jpg out=50 \
    http://example.com/image2.jpg out=75 -mix 25 -mixer luma \
    http://example.com/image3.jpg out=75 -mix 25 -mixer luma \
    http://example.com/image4.jpg out=75 -mix 25 -mixer luma \
    http://example.com/image5.jpg out=75 -mix 25 -mixer luma \
    -consumer avformat:output.mp4 vcodec=libx264 an=1
    

    But it gives

    No LADSPA plugins were found!
    
    Check your LADSPA_PATH environment variable.
    

    and full output is

    No LADSPA plugins were found!
    
    Check your LADSPA_PATH environment variable.
    [mjpeg @ 0x168a320] Changeing bps to 8
    [mjpeg @ 0x12725a0] Changeing bps to 8
    [mjpeg @ 0x1691120] Changeing bps to 8
    [mjpeg @ 0x1bc5ac0] Changeing bps to 8
    [mjpeg @ 0x1907ae0] Changeing bps to 8
    [mjpeg @ 0x1d09a20] Changeing bps to 8
    [mjpeg @ 0x13a2b00] Changeing bps to 8
    [mjpeg @ 0x1e4e6e0] Changeing bps to 8
    [mjpeg @ 0x1d0b8c0] Changeing bps to 8
    [mjpeg @ 0x1d190c0] Changeing bps to 8
    +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
    |1=-10| |2= -5| |3= -2| |4= -1| |5=  0| |6=  1| |7=  2| |8=  5| |9= 10|
    +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
    +---------------------------------------------------------------------+
    |               H = back 1 minute,  L = forward 1 minute              |
    |                 h = previous frame,  l = next frame                 |
    |           g = start of clip, j = next clip, k = previous clip       |
    |                0 = restart, q = quit, space = play                  |
    +---------------------------------------------------------------------+
    [libx264 @ 0x7f7f980c7aa0] using SAR=1/1
    [libx264 @ 0x7f7f980c7aa0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
    [libx264 @ 0x7f7f980c7aa0] profile High, level 3.1
    [libx264 @ 0x7f7f980c7aa0] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=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 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 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 keyint_min=25 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
    [mjpeg @ 0x7f7f88433200] Changeing bps to 8
    [mjpeg @ 0x7f7f88832980] Changeing bps to 8
    [mjpeg @ 0x7f7f88052ac0] Changeing bps to 8
    [mjpeg @ 0x7f7f88c5abe0] Changeing bps to 8
    [mjpeg @ 0x7f7f88bdd560] Changeing bps to 8
    [mjpeg @ 0x7f7f88beb2a0] Changeing bps to 8
    [mjpeg @ 0x7f7f88c838a0] Changeing bps to 8
    [mjpeg @ 0x7f7f894a1100] Changeing bps to 8
    [mjpeg @ 0x7f7f88b6a3a0] Changeing bps to 8
    [mjpeg @ 0x7f7f88b78840] Changeing bps to 8
    [swscaler @ 0x7f7f88c5f740] YUV color matrix differs for YUV->YUV, using intermediate RGB to convert
    [swscaler @ 0x7f7f88c5f740] YUV color matrix differs for YUV->YUV, using intermediate RGB to convert
    [swscaler @ 0x7f7f898cc980] Warning: data is not aligned! This can lead to a speedloss
    [swscaler @ 0x7f7f88c5f740] YUV color matrix differs for YUV->YUV, using intermediate RGB to convert
    [swscaler @ 0x7f7f88c5f740] YUV color matrix differs for YUV->YUV, using intermediate RGB to convert
    [swscaler @ 0x7f7f88c5f740] YUV color matrix differs for YUV->YUV, using intermediate RGB to convert
    [mjpeg @ 0x7f7f89ff25a0] Changeing bps to 8
    Segmentation fault (core dumped)
    

    Also, the generated video file is broken

    How can I provide http input?

  • Multiple audio tracks from one source in ffmpeg

    26 décembre 2017, par IanBauters

    I'm transcoding my video using ffmpeg but I am unable to figure out how I can get both a 2 channel aac option (downmuxed) and a surround AC3 option in one go. My current command is:

    ffmpeg -i input.mp4 \
    -c:v libx265 -preset medium -crf 21 -pix_fmt yuv420p10le \
    -tag:v hvc1 \
    -c:a libfdk_aac -b:a 320k \
    -c:a ac3 -b:a 512k \
    movie_10bit.m4v
    

    But I only get surround out of this. All help is much appreciated.