Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Improve ffmpeg performance

    8 décembre 2014, par hitesh

    I am using ffmpeg to take screen shot from video , it is video from CDN.

    I am doing below steps

    1.Upload video to CDN using html file tag.

    2.Get CDN url and use it for creating screen shot using ffmpeg.

    3.Upload the screenshot in CDN.

    4.Save video and screenshot CDN url to DB

    the whole process is really time consuming, even if I put loader it is really slow.

    This is code of POC I did for ffmpeg :

    $imageFile = realpath("./videos") . '/test5.png';
    $imageFile2 = realpath("./videos") . '/test6.png';
    $size = "230x155";
    $getfromsecond = 8;
    
    if (isEnabled('shell_exec')) {
        echo "Shall_exec is enabled " . "
    "; shell_exec('echo "hello world"'); echo "
    "; } else { echo "shall exec command is not allowed"; } $cmd = "ffmpeg -i $vid -an -ss $getfromsecond -s $size -vframes 1 $imageFile"; $cmd2 = "ffmpeg -i $remoteVideo -an -ss $getfromsecond -s $size -vframes 1 $imageFile2"; echo 'command 1 - local Image : ' . $cmd . "
    "; echo 'command 2 - remote video : ' . $cmd2 . "
    "; echo "
    command 2 - remote video shell_exec output : " . shell_exec($cmd) . "
    "; echo '
    command 2 - remote video shell_exec output : ' . shell_exec($cmd2) . "
    "; if (!shell_exec($cmd)) { echo " video Thumbnail created" . "
    "; } else { echo "Error Creating video thumbnail" . "
    "; } if (!shell_exec($cmd2)) { echo "Remote video Thumbnail created" . "
    "; } else { echo "Error Creating Remote video thumbnail" . "
    "; } function isEnabled($func) { return is_callable($func) && false === stripos(ini_get('disable_functions'), $func); }

    Is there some way to improve ffmpeg performance ?

    Thanks

  • FFmpeg : Invalid data found when processing input after created a video slideshow from images

    8 décembre 2014, par David Zhuang

    FFmpeg provides some examples of making slideshow from image(s):

    https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images

    So I 've tried this command:

    ffmpeg -loop 1 -t 10 -framerate 24 -i '1.png' -c:v libx264 -crf 36 -vf scale=640:360 -pix_fmt yuv420p -shortest 2.mp4
    

    It is a success generating a MP4 file. Also there's no problem remuxing it into FLV.

    FFmpeg gave no no error when I mux the video stream into .h264 .

    But when I tried to process this file further, ffmpeg gave me this error:

    $ffmpeg -i 2.h264 ffmpeg version 2.4.3 Copyright (c) 2000-2014 the FFmpeg developers built on Nov 4 2014 11:01:51 with llvm-gcc 4.2.1 (LLVM build 2336.11.00) configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --enable-libvidstab --enable-libx265 --arch=x86_64 --enable-runtime-cpudetect libavutil 54. 7.100 / 54. 7.100 libavcodec 56. 1.100 / 56. 1.100 libavformat 56. 4.101 / 56. 4.101 libavdevice 56. 0.100 / 56. 0.100 libavfilter 5. 1.100 / 5. 1.100 libswscale 3. 0.100 / 3. 0.100 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 0.100 / 53. 0.100 2.h264: Invalid data found when processing input

    (OSX 10.10.1, with binary from http://ffmpegmac.net/ )

    This problem can be reproduced on another Ubuntu 12.04 x64 machine:

    # ffmpeg -i 2.h264 -c copy 2.flv ffmpeg version 2.3.git Copyright (c) 2000-2014 the FFmpeg developers built on Aug 3 2014 13:42:36 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-nonfree libavutil 52. 94.100 / 52. 94.100 libavcodec 55. 71.100 / 55. 71.100 libavformat 55. 50.100 / 55. 50.100 libavdevice 55. 13.102 / 55. 13.102 libavfilter 4. 11.102 / 4. 11.102 libswscale 2. 6.100 / 2. 6.100 libswresample 0. 19.100 / 0. 19.100 libpostproc 52. 3.100 / 52. 3.100 2.h264: Invalid data found when processing input

    So what the problem with this file?

  • How to encode downloaded m3u8 video using ffmpeg ?

    8 décembre 2014, par Patrick Alessi

    I have found a lot of guides to download and convert live streams using ffmpeg. My problem is that i have downloaded a tv show using the video downloader app for ipad, transfarred the .ts files and m3u8 file to my mac.

    How do I convert it into an mp4 og mkv file using ffmpeg now that the files are located on my local hard drive?

    I have tried converting each clip with a video converter but they are rendered with gaps, and other problems...

    I need it to play as smooth as on an ipad but on my mac.

    I have no idea how ffmpeg works. I just follow a tutorial to make the installation. and i dont know how to set up virtuel servers...

  • Recording screencast using ffmpeg produces audio that is out of sync with the video

    7 décembre 2014, par AgilE

    I'm on Fedora 20. I got it pre-compiled from the repo.

    I use the follow command to record screencasts:

    ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 30 -s 1366x768 -i :0.0 -acodec pcm_s16le -vcodec libx264 -preset ultrafast -crf 0 -threads 0 filename.mkv
    

    The audio is perfectly synced with the video at the beginning. However, as the video progresses, the audio starts lagging behind severely (say a lag of more than 4 seconds). I've included a sample output that ffmpeg shows while recording a video.

    ffmpeg version 2.1.3 Copyright (c) 2000-2013 the FFmpeg developers
      built on Jan 25 2014 15:11:42 with gcc 4.8.2 (GCC) 20131212 (Red Hat 4.8.2-7)
      configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-frei0r --enable-gnutls --enable-libass --enable-libcdio --enable-libcelt --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
      libavutil      52. 48.101 / 52. 48.101
      libavcodec     55. 39.101 / 55. 39.101
      libavformat    55. 19.104 / 55. 19.104
      libavdevice    55.  5.100 / 55.  5.100
      libavfilter     3. 90.100 /  3. 90.100
      libavresample   1.  1.  0 /  1.  1.  0
      libswscale      2.  5.101 /  2.  5.101
      libswresample   0. 17.104 /  0. 17.104
      libpostproc    52.  3.100 / 52.  3.100
    Guessed Channel Layout for  Input Stream #0.0 : stereo
    Input #0, alsa, from 'pulse':
      Duration: N/A, start: 1391533629.323015, bitrate: 1536 kb/s
        Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
    [x11grab @ 0x153ad80] device: :0.0 -> display: :0.0 x: 0 y: 0 width: 1366 height: 768
    [x11grab @ 0x153ad80] shared memory extension found
    Input #1, x11grab, from ':0.0':
      Duration: N/A, start: 1391533629.365274, bitrate: 1007124 kb/s
        Stream #1:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1366x768, 1007124 kb/s, 30 tbr, 1000k tbn, 30 tbc
    [swscaler @ 0x1520460] deprecated pixel format used, make sure you did set range correctly
    No pixel format specified, yuv444p for H.264 encoding chosen.
    Use -pix_fmt yuv420p for compatibility with outdated media players.
    [libx264 @ 0x1551420] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    [libx264 @ 0x1551420] profile High 4:4:4 Predictive, level 3.2, 4:4:4 8-bit
    [libx264 @ 0x1551420] 264 - core 138 r2363 c628e3b - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
    Output #0, matroska, to 'testing.mkv':
      Metadata:
        encoder         : Lavf55.19.104
        Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 1366x768, q=-1--1, 1k tbn, 30 tbc
        Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
    Stream mapping:
      Stream #1:0 -> #0:0 (rawvideo -> libx264)
      Stream #0:0 -> #0:1 (pcm_s16le -> pcm_s16le)
    Press [q] to stop, [?] for help
    [swscaler @ 0x1520460] Warning: data is not aligned! This can lead to a speedloss
    frame=  213 fps= 27 q=-1.0 Lsize=    3572kB time=00:00:08.00 bitrate=3653.6kbits/s    
    video:2025kB audio:1501kB subtitle:0 global headers:0kB muxing overhead 1.291094%
    [libx264 @ 0x1551420] frame I:1     Avg QP: 0.00  size:692585
    [libx264 @ 0x1551420] frame P:212   Avg QP: 0.00  size:  6509
    [libx264 @ 0x1551420] mb I  I16..4: 100.0%  0.0%  0.0%
    [libx264 @ 0x1551420] mb P  I16..4: 47.2%  0.0%  0.0%  P16..4:  0.1%  0.0%  0.0%  0.0%  0.0%    skip:52.8%
    [libx264 @ 0x1551420] coded y,u,v intra: 0.7% 0.7% 0.7% inter: 0.1% 0.1% 0.1%
    [libx264 @ 0x1551420] i16 v,h,dc,p: 100%  0%  0%  0%
    [libx264 @ 0x1551420] kb/s:2335.32
    

    Is there something I'm missing?

  • Install newset FFProbe in Ubuntu [on hold]

    7 décembre 2014, par Vivendi

    I've downloaded the PHP-FFMpeg library and I installed both ffmpeg and ffprobe on my Ubuntu LTS server. But when I try to text the library I get the following error:

    Fatal error: Uncaught exception 'Alchemy\BinaryDriver\Exception\ExecutionFailureException' with message 'ffprobe failed to execute command '/usr/bin/ffprobe' '-help' '-loglevel' 'quiet''

    I've read that new versions of FFProbe have the -help option. My installation seems to be missing this options, so I suspect that this is the problem. But how do I install a new version of FFProbe on my Linux server?

    I installed it with apt-get install ffprobe, but that seems to give me an old version. Where can I get and install a new one?