Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • how to record video of selenium tests running on Xvfb ?

    3 février 2016, par user299709

    I want a video recording of my selenium tests (chromedriver running on linux server with Xvfb).

    How would you go about doing this with ffmpeg or does a library already exist? I also would like the output to be a choppy gif (I just need to know the basics of what is happening).

  • Getting log line for each extracted frame from FFMPEG

    3 février 2016, par wpfwannabe

    I am using FFMPEG.exe to extract frames from various videos. As this is a programmatic solution and getting the total frame count and/or duration can prove tricky (with ffprobe), I am thinking I could use the console output to detect individual frames' timestamps but I am getting a single output line every N frames like this:

    frame=   20 fps=0.0 q=0.0 size=       0kB time=00:00:01.72 bitrate=   0.0kbits/s
    frame=   40 fps= 38 q=0.0 size=       0kB time=00:00:04.02 bitrate=   0.0kbits/s
    frame=   60 fps= 39 q=0.0 size=       0kB time=00:00:06.14 bitrate=   0.0kbits/s
    frame=   70 fps= 38 q=0.0 Lsize=       0kB time=00:00:07.86 bitrate=   0.0kbits/s
    

    Is there a command line option to force output for each and every frame? If so, I could extract the time= portion. This is the command line currently used:

    ffmpeg.exe -i video.avi -y -threads 0 -vsync 2 %10d.jpeg
    

    Ideally, replacing %10d.jpeg with some other format that writes frame's timestamp but I don't think this exists.

  • Detect rotation angle and rotate final video using ffmpeg version 2.8

    3 février 2016, par Hemant Kumar

    I used to work on ffmpeg 2.2 until now and was detecting rotation angle of video uploaded from android / iPhone mobiles and rotate the resulting video so that it run perfectly on a correct angle.

    But since I have updated the ffmpeg to version 2.8 I am getting this rotation problem. My queries are not rotating the videos as they were earlier.

    Here'r the commands I was using:

    To check rotation angle:

    ffprobe -of json -show_streams {$input} | grep rotate
    

    below is my final command to convert a video to mp4

    "ffmpeg -i {$input} -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ".fix_video_orientation($input)."' -threads 0 -ab 64k -s {$resolution}  -movflags faststart -metadata:s:v:0 rotate=0 {$output}";
    

    "fix_video_orientation" function is given below. It detect the angle of rotation of the initial video and output optimal option for rotating the final video.

    function fix_video_orientation($input){
    
    $return= ", transpose=1 ";
    
    $dd= exec("ffprobe -of json -show_streams  {$input}   | grep rotate");
    
    if(!empty($dd)){
    
    $dd=explode(":",$dd);
    $rotate=str_replace(",","",str_replace('"',"",$dd[1]));
    
    if($rotate=="90")return $return;
    
    else if ($rotate=="180") return ", transpose=2,transpose=2 ";
    
    else if($rotate == "270") return ", transpose=2 ";
    }
    

    Currently above script is supporting "flv","avi","mp4","mkv","mpg","wmv","asf","webm","mov","3gp","3gpp" extensions, also the script is supporting the resulting .mp4 file to play on all browsers and devices.

    Now the ffprobe command is not returning rotation angle and so a portrait video if uploaded from iphone is showing as landscape on the website.

    Output console of ffprobe command:

    ffprobe version N-77455-g4707497 Copyright (c) 2007-2015 the FFmpeg developers
    built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
    configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libdcadec --enable-libfreetype --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvo-aacenc --enable-libvidstab
    libavutil 55. 11.100 / 55. 11.100
    libavcodec 57. 20.100 / 57. 20.100
    libavformat 57. 20.100 / 57. 20.100
    libavdevice 57. 0.100 / 57. 0.100
    libavfilter 6. 21.101 / 6. 21.101
    libavresample 3. 0. 0 / 3. 0. 0
    libswscale 4. 0.100 / 4. 0.100
    libswresample 2. 0.101 / 2. 0.101
    libpostproc 54. 0.100 / 54. 0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/standard/PORTRAIT.m4v':
    Metadata:
    major_brand : qt
    
    minor_version : 0
    compatible_brands: qt
    
    creation_time : 2016-02-03 05:25:18
    com.apple.quicktime.make: Apple
    com.apple.quicktime.model: iPhone 4S
    com.apple.quicktime.software: 9.2.1
    com.apple.quicktime.creationdate: 2016-02-03T10:52:11+0530
    Duration: 00:00:03.34, start: 0.000000, bitrate: 7910 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
    Metadata:
    creation_time : 2016-02-03 05:25:18
    handler_name : Core Media Data Handler
    Stream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x1280 [SAR 1:1 DAR 9:16], 7832 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 50 tbc (default)
    Metadata:
    creation_time : 2016-02-03 05:25:18
    handler_name : Core Media Data Handler
    encoder : H.264
    Stream #0:2(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
    Metadata:
    creation_time : 2016-02-03 05:25:18
    handler_name : Core Media Data Handler
    Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
    Metadata:
    creation_time : 2016-02-03 05:25:18
    handler_name : Core Media Data Handler
    Unsupported codec with id 0 for input stream 2
    Unsupported codec with id 0 for input stream 3
    

    If latest version of ffmpeg (2.8) is used to auto rotate the video, can you please suggest me what option I need to add or remove from my final command.

  • adaptive compression with ffmpeg

    3 février 2016, par paunescuionica

    I'm currently developing an application which will enable visualizing images from different sources (mostly IP cameras) in browser (in a HTML5 video element). The UI will allow for matrix view so, normally 16 or more cameras will be displayed at the same time. From cameras I get MJPEG streams or JPEG images (which I "convert" to MJPEG streams). So, for a camera, I have an MJPEG stream which I set as input for ffmpeg. I instruct ffmpeg to convert this to MP4 & H.264, and expose the output as a tcp stream, like this:

    ffmpeg -f mjpeg -i "http://localhost/video.mjpg" -f mp4 -vcodec libx264 "tcp://127.0.0.1:5001?listen"

    This works just fine on localhost, I get the stream displayed in the web page, at best quality.

    But this has to work in various network conditions. I played a bit with chrome throttling settings, and noticed that if the network speed is just a bit below the required speed (given by the current compression settings I use in ffmpeg), the things start to go wrong: from stream start being delayed (so, no longer a live stream), up to complete freeze of 'live' image in browser.

    What I need is an "adaptive" way to do the compression, in relation with current network speed.

    My questions are:

    • is ffmpeg able to handle this, to adapt to network conditions - automatically reduce compression quality when speed is low; so the image in browser will be lower quality, but live (which is most important in my case)

    • if not, is there a way to workaround this?

    • is there a way to detect the network bottleneck? (and then restart ffmpeg with lower compression parameters; this is not a dynamic adaptive streaming, but better than nothing)

    Thank you in advance!

  • is it possible to read mp3 id3 tags in php using ffmpeg ? if so then how ? [on hold]

    3 février 2016, par Assassiŋ Shaɖow

    Hi i have a few mp3 files in my server which constantly change and i need the mp3 id3 tags for people to know what song is being played at the moment preferably via php . I am a complete noob at this so any help is helpful.