Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Identify a specific frame number of a video file

    23 février 2017, par James Crampton

    I have a video file from which I've extracted a specific frame to analyze. However, I want to know what the frame number of this frame is.
    I can't seem to find anything. I've had a look at ffmpeg showinfo, but that doesn't seem to work.
    I've also looked into exifread, which produced information about the frame - except for the frame number.

    Any ideas?

  • WebM live streaming via DASH

    23 février 2017, par ewack

    I am following the instructions here to try to make WebM live streaming via DASH. My input is from an Axis camera and it is streaming as h264 encoding. I am using node to spin up the ffmpeg processes. I am able to create the .hdr file and the .chk files. The .mpd file is even created but it's empty and I get an error saying:

    Could not write header for output file #0 (incorrect codec parameters ?): Operation not permittedStream mapping: Stream #0:0 -> #0:0 (copy)
    

    Here's all of my code:

    var express = require('express');
    spawn = require('child_process').spawn;
    
    var app = express();
    
    app.use(express.static(__dirname + '/public'));
    
    app.listen(8080);
    console.log("Running on Port 8080");
    
    var ffmpeg1 = spawn('ffmpeg', [
        '-y',
        //video
        '-i', 'rtsp://admin:password@192.168.1.54:554/axis-media/media.amp?videocodec=h264&resolution=1280x720',
    
        '-map', '0:0',
        '-pix_fmt', 'yuv420p',
        '-color_range', '2',
        '-c:v', 'libvpx-vp9',
    
        '-s', '1280x720',
        '-keyint_min', '25',
        '-g', '25', 
    
        // //VP9_LIVE_PARAMS
        '-speed', '6', 
        '-tile-columns', '4',
        '-frame-parallel', '1', 
        '-threads', '8', 
        '-static-thresh', '0', 
        '-max-intra-rate', '300',
        '-deadline', 'realtime', 
        '-lag-in-frames', '0',
        '-error-resilient', '1',
    
        '-f', 'webm_chunk',
        '-header', 'public/glass_360.hdr',
        '-chunk_start_index', '1',
        'public/glass_360_%d.chk',
    ]);
    
    
    setTimeout(()=> {
      var ffmpeg2 = spawn('ffmpeg', [
        '-y',
        '-f', 'webm_dash_manifest',
        '-live', '1',
        '-i', 'public/glass_360.hdr',
        '-c', 'copy',
        '-map', '0',
        '-r', '25',
        '-framerate', '25',
    
        '-f', 'webm_dash_manifest',
        '-live', '1',
    
        '-adaptation_sets', '"id=0,streams=0"',
        '-chunk_start_index', '1',
        '-chunk_duration_ms', '2000',
        '-time_shift_buffer_depth', '7200',
        '-minimum_update_period', '7200',
    
        'public/glass_live_manifest.mpd'
      ]);
      ffmpeg2.stdout.on('data', 
          function (data) {
              console.log('ff2std: ' + data);
          }
      );
    
      ffmpeg2.stderr.on('data', 
          function (data) {
              console.log('ff2err: ' + data);
          }
      );
    }, 5000);
    
    ffmpeg1.stdout.on('data', 
        function (data) {
            console.log('ff1std: ' + data);
        }
    );
    
    ffmpeg1.stderr.on('data', 
        function (data) {
            console.log('ff1err: ' + data);
        }
    );
    

    Here is all of my output:

    Running on Port 8080
    ff1err: ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
      built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
      configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-frei0r --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.1.2/include/openjpeg-2.1 --enable-nonfree --enable-vda
    
    ff1err:   libavutil      55. 34.101 / 55. 34.101
      libavcodec     57. 64.101 / 57. 64.101
      libavformat    57. 56.101 / 57. 56.101
      libavdevice    57.  1.100 / 57.  1.100
      libavfilter     6. 65.100 /  6. 65.100
      libavresample   3.  1.  0 /  3.  1.  0
      libswscale      4.  2.100 /  4.  2.100
      libswresample   2.  3.100 /  2.  3.100
      libpostproc    54.  1.100 / 54.  1.100
    
    ff1err: Input #0, rtsp, from 'rtsp://admin:password@192.168.1.54:554/axis-media/media.amp?videocodec=h264&resolution=1280x720':
      Metadata:
        title           : Session streamed with GStreamer
        comment         : rtsp-server
      Duration: N/A, start: 0.033344
    ff1err: , bitrate: N/A
        Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 180k tbc
    
    ff1err: [swscaler @ 0x7f8df281bc00] deprecated pixel format used, make sure you did set range correctly
    
    ff1err: [libvpx-vp9 @ 0x7f8df2800600] v1.6.1
    
    ff1err: Output #0, webm_chunk, to 'public/glass_360_%d.chk':
      Metadata:
        title           : Session streamed with GStreamer
        comment         : rtsp-server
        encoder         : Lavf57.56.101
    
    ff1err:     Stream #0:0: Video: vp9 (libvpx-vp9), yuv420p(pc), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 200 kb/s, 25 fps, 1k tbn, 25 tbc
        Metadata:
          encoder         : Lavc57.64.101 libvpx-vp9
        Side data:
          cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream mapping:
      Stream #0:0 -> #0:0 (h264 (native) -> vp9 (libvpx-vp9))
    Press [q] to stop, [?] for help
    
    ff1err: frame=   10 fps=0.0 q=0.0 size=N/A time=00:00:00.36 bitrate=N/A speed=0.71x    
    ff1err: frame=   25 fps= 25 q=0.0 size=N/A time=00:00:00.96 bitrate=N/A speed=0.946x    
    ff1err: frame=   40 fps= 26 q=0.0 size=N/A time=00:00:01.56 bitrate=N/A speed=1.03x    
    ff1err: frame=   55 fps= 27 q=0.0 size=N/A time=00:00:02.16 bitrate=N/A speed=1.07x    
    ff1err: frame=   70 fps= 28 q=0.0 size=N/A time=00:00:02.76 bitrate=N/A speed=1.09x    
    ff1err: frame=   85 fps= 28 q=0.0 size=N/A time=00:00:03.36 bitrate=N/A speed=1.11x    
    ff2err: ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
      built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
      configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-frei0r --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.1.2/include/openjpeg-2.1 --enable-nonfree --enable-vda
    
    ff2err:   libavutil      55. 34.101 / 55. 34.101
      libavcodec     57. 64.101 / 57. 64.101
      libavformat    57. 56.101 / 57. 56.101
      libavdevice    57.  1.100 / 57.  1.100
      libavfilter     6. 65.100 /  6. 65.100
      libavresample   3.  1.  0 /  3.  1.  0
      libswscale      4.  2.100 /  4.  2.100
      libswresample   2.  3.100 /  2.  3.100
      libpostproc    54.  1.100 / 54.  1.100
    
    ff2err: [webm_dash_manifest @ 0x7fbc5b80b400] Could not find codec parameters for stream 0 (Video: vp9, none, 1280x720): unspecified pixel format
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    
    ff2err: Input #0, webm_dash_manifest, from 'public/glass_360.hdr':
      Metadata:
        title           : Session streamed with GStreamer
        encoder         : Lavf57.56.101
      Duration: N/A, bitrate: N/A
        Stream #0:0: Video: vp9, none, 1280x720
    ff2err: , SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
        Metadata:
          webm_dash_manifest_file_name: glass_360.hdr
          webm_dash_manifest_track_number: 1
    
    ff2err: Could not write header for output file #0 (incorrect codec parameters ?): Operation not permittedStream mapping:
      Stream #0:0 -> #0:0 (copy)
    
    ff2err:     Last message repeated 1 times
    
    ff1err: frame=  101 fps= 29 q=0.0 size=N/A time=00:00:04.00 bitrate=N/A speed=1.13x    
    ff1err: frame=  116 fps= 29 q=0.0 size=N/A time=00:00:04.60 bitrate=N/A speed=1.14x    
    ff1err: frame=  131 fps= 29 q=0.0 size=N/A time=00:00:05.20 bitrate=N/A speed=1.15x    
    ff1err: frame=  146 fps= 29 q=0.0 size=N/A time=00:00:05.80 bitrate=N/A speed=1.15x    
    ff1err: frame=  161 fps= 29 q=0.0 size=N/A time=00:00:06.40 bitrate=N/A speed=1.15x    
    ff1err: frame=  177 fps= 29 q=0.0 size=N/A time=00:00:07.04 bitrate=N/A speed=1.16x    
    ff1err: frame=  192 fps= 29 q=0.0 size=N/A time=00:00:07.64 bitrate=N/A speed=1.16x    
    ff1err: frame=  207 fps= 29 q=0.0 size=N/A time=00:00:08.24 bitrate=N/A speed=1.16x    
    ff1err: frame=  222 fps= 29 q=0.0 size=N/A time=00:00:08.84 bitrate=N/A speed=1.17x    
    ff1err: frame=  237 fps= 29 q=0.0 size=N/A time=00:00:09.44 bitrate=N/A speed=1.17x    
    ff1err: frame=  252 fps= 29 q=0.0 size=N/A time=00:00:10.04 bitrate=N/A speed=1.17x  
    

    Why is ffmpeg creating an empty .mpd file?

  • Bash : bash script to download trimmed mp3 from youtube url

    23 février 2017, par Bhishan Poudel

    I would like to download the initially x seconds trimmed mp3 from a video url of youtube.
    I found that youtube-dl can download the video from youtube to local machine. But, when I looked at the man pages of youtube-dl, I could not find any trim options.

    So I tried to use the ffmpeg to trim downloaded mp3 file.
    Instead of doing this is two steps, I like to write one bash script which does the same thing.
    My attempt is given below.

    However, I was stuck at one place:
    "HOW TO GET THE VARIABLE NAME OF OUTPUT MP3 FILE FROM YOUTUBE-DL?"
    The script is given below:

    # trim initial x seconds of mp3 file
    # e.g. mytrim https://www.youtube.com/watch?v=dD5RgCf1hrI 30
    function mytrim() {
        youtube-dl --extract-audio --embed-thumbnail --audio-format mp3 -o "%(title)s.%(ext)s" $1
        ffmpeg -ss $2 -i $OUTPUT_MP3 -acodec copy -y temp.mp3
        mv temp.mp3 $OUTPUT_MP3
        }
    

    How to get the variable value $OUTPUT_MP3?
    echo "%(title)s.%(ext)s" gives the verbatim output, does not give the output filename.

    How could we make the script work?

    The help will be appreciated.

  • FFmpeg. Loosing timecode while transcoding

    23 février 2017, par 7sides

    I've got an mp4 (h264) file from RTSP webcam with dynamic FPS (~10).

    I can see that mp4 STTS atom contains right frames durations/deltas when a frame is skipped (due to networking problems for instance).

    So at playing I always have the right total duration for about 30 minutes.

    But when I transcode this file to mpegts format and back to mp4 the total duration becomes approx. 29:10 (seems due to missed frames and normalising of PTS).

    Here are the commands:

    Convert from mp4 to mpegts:

    ffmpeg -copyts -i /script_cache/_1487864096/10.8.0.118_rtsp.camera.1.hall_1487831449.mp4 -c copy -y -bsf:v h264_mp4toannexb -copyts -f mpegts /script_cache/_1487864096/10.8.0.118_rtsp.camera.1.hall_1487831449.ts
    

    Convert from mpegts to mp4:

    ffmpeg -copyts -i /script_cache/_1487864096/10.8.0.118_rtsp.camera.1.hall_1487831449.ts -c copy -f mp4 result.mp4
    

    So, how can I preserve the source duration/deltas while converting mp4->mpegts->mp4?

  • ffmpeg encode video en VBR

    23 février 2017, par Aminesrine

    I want to transcode a video en VBR (Variable Bit Rate) with Ffmpeg. I added to my commande Ffmpeg thes options: -q:v n1 and -q:a n2 I want to have 4 files video for the differents bitrate (1500,850,450 et 250) In the encoding en CBR I use :

    - `-b:v 1308k` and `-q:a 192k` for the bitrate 1500
    - `-b:v 754k` and `-q:a 96k` for the bitrate 850
    - `-b:v 402k` and `-q:a 48k` for the bitrate 450
    - `-b:v 228k` and `-q:a 22k` for the bitrate 250
    

    What values can I use with options -q:v n1 and -q:a n2 to have the 4 bitrates.