VideoHelp Forum
+ Reply to Thread
Results 1 to 16 of 16
Thread
  1. Member
    Join Date
    Jul 2008
    Location
    Sweden
    Search Comp PM
    I am using ffmpeg and ffmpeg-php to grab some screens from movies to use as thumbnails for the movies on my website.

    This whole setup works just great for most stuff like xvid and others.

    Hoever it refuses to work with wmv files (created with windows movie maker) and also .mov files created with casio cameras with h.264 content.

    But most importantly it fails on my main cameras videos (samsung nv24hd) which has mp4 videos also containing h.264 content.

    My question is of course if there is any way to make this work, install codecs etc, if so where can i find them?
    Or anything else?

    I updated to latest ffmpeg build, but still no good.
    Quote Quote  
  2. Get Slack disturbed1's Avatar
    Join Date
    Apr 2001
    Location
    init 4
    Search Comp PM
    What's the error message? And - did you compile in support for those formats?

    If you do a ffmpeg -formats from the command line it will give you some information D=decode E=encode A=audio V=video forget what S and D are.

    For wmv you want -
    DEA wmav1 Windows Media Audio 1
    DEA wmav2 Windows Media Audio 2
    DEVSD wmv1 Windows Media Video 7
    DEVSD wmv2 Windows Media Video 8
    D V wmv3 Windows Media Video 9

    Look for quicktime/mov and x264/mp4.

    Here's the config options for my ffmpeg

    $ ffmpeg -formats
    FFmpeg version SVN-r14332, Copyright (c) 2000-2008 Fabrice Bellard, et al.
    configuration: --prefix=/usr --mandir=/usr/man --disable-debug --enable-shared --disable-static --enable-postproc --enable-swscale --enable-pthreads --enable-liba52 --enable-liba52bin --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-gpl
    libavutil version: 49.7.0
    libavcodec version: 51.60.0
    libavformat version: 52.17.0
    libavdevice version: 52.0.0
    built on Jul 22 2008 03:03:36, gcc: 4.2.3
    File formats:

    BIG LONG STREAM OF FORMATS
    DELETED BECAUSE IT'S A WALL OF TEXT
    Also check to see if VLC or Mplayer can play the files. VLC and mplayer use the ffmpeg libraries to decode. If one or both can play the file, then it is possible to have ffmpeg decode it as well. Or post up a small sample file for one of us to play with.
    Linux _is_ user-friendly. It is not ignorant-friendly and idiot-friendly.
    Quote Quote  
  3. Member
    Join Date
    Jul 2008
    Location
    Sweden
    Search Comp PM
    Thank you for your reply!

    I don't know where I can find the error messages, not to good at using the linux.
    And I can't play it in vlc either because the linux box doesnt have a graphical interface to it.

    I did however do ffmpeg -formats and this is what came up

    DEA wmav1 Windows Media Audio 1
    DEA wmav2 Windows Media Audio 2
    DEVSD wmv1 Windows Media Video 7
    DEVSD wmv2 Windows Media Video 8
    D V wmv3 Windows Media Video 9

    So that seems correct. As for H.264 I have this line

    D V D h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10

    Finally wmv isn't even in the list of File formats, maybe that explains why that doesn't work?

    Here is a file that the code fails on: http://www.rickardliljeberg.com/media.php?itemID=3003
    That is for mp4 / h.264 (this is the most important one to get working)

    here is also a failed wmv file http://www.rickardliljeberg.com/media.php?itemID=2795

    Here is how it looks when it succeeds: http://www.rickardliljeberg.com/media.php?itemID=2963 this is a regular xvid.

    Under fileformats I can however see some problems because both .mov and .mp4 onlye has an E like this:
    E mp4 MP4 format
    E mov MOV format

    however there is also this line
    D mov,mp4,m4a,3gp,3g2,mj2 QuickTime/MPEG-4/Motion JPEG 2000 format

    which makes me a bit confused
    Quote Quote  
  4. Get Slack disturbed1's Avatar
    Join Date
    Apr 2001
    Location
    init 4
    Search Comp PM
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SDC10354.MP4':
    Duration: 00:00:25.82, start: 0.000000, bitrate: 6725 kb/s
    Stream #0.0(und): Video: h264, yuv420p, 1280x720, 29.97 tb(r)
    Stream #0.1(und): Audio: libfaad, 48000 Hz, stereo
    Output #0, avi, to 'out.avi':
    Stream #0.0(und): Video: mpeg4, yuv420p, 1280x720, q=2-31, 200 kb/s, 29.97 t b(c)
    Stream #0.1(und): Audio: mp2, 48000 Hz, stereo, 64 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0
    Stream #0.1 -> #0.1
    Press [q] to stop encoding
    [h264 @ 0x806b8f0]B picture before any references, skipping
    [h264 @ 0x806b8f0]decode_slice_header error
    [h264 @ 0x806b8f0]no frame!
    Error while decoding stream #0.0
    [h264 @ 0x806b8f0]B picture before any references, skipping
    [h264 @ 0x806b8f0]decode_slice_header error
    [h264 @ 0x806b8f0]no frame!
    Error while decoding stream #0.0
    My ffmpeg decodes/encodes the stream. There are a couple of errors, but it does read it and finish the encode. This is for http://www.rickardliljeberg.com/media.php?itemID=3003 .

    Perhaps (?) the frame number that you are attempting to get a screen shot of is a bad frame? Some where in your script there should be a setting for which frame number it attempts to grab. Try adjusting that.

    Here's for the wmv
    [wmv3 @ 0x806fba0]Extra data: 8 bits left, value: 0

    Seems stream 1 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1)
    Input #0, asf, from 'svensexa_warmup.wmv':
    Duration: 00:01:01.11, start: 5.000000, bitrate: 1829 kb/s
    Stream #0.0: Audio: wmav2, 48000 Hz, stereo, 192 kb/s
    Stream #0.1: Video: wmv3, yuv420p, 768x576, 1574 kb/s, 25.00 tb(r)
    Notice [wmv3 @ 0x806fba0]Extra data: 8 bits left, value: 0 . Try adjusting which frame your script attempts to capture and let us know how it works.

    Also, you stated a recent build of ffmpeg is installed. Which distro are you using, what is the ffmpeg package called, and (sorry for so many questions) where did you get it from?
    Linux _is_ user-friendly. It is not ignorant-friendly and idiot-friendly.
    Quote Quote  
  5. Member
    Join Date
    Jul 2008
    Location
    Sweden
    Search Comp PM
    this is what i do in my code

    ------

    $mov = new ffmpeg_movie($resizeName);
    $framecount = $mov->getFrameCount();

    //not sure it's correct data, we'll have to create an approx amount of frames OBS all the code in here is just to get approx values that will do the job, finally we make sure the last frames actually do work !
    if(!isset($framecount) || $framecount <= 10 || !is_object($mov->getFrame($framecount-1)))
    {
    $framecount = -1; //Just getting the framecount failed so we reset the variable

    //with the framerate and duration we can get an apporx amount of frames
    $framerate = $mov->getFrameRate();
    if(!isset($framerate) || $framerate <= 2) //we cant get the framerate so we'll guess a low one
    $framerate = 10;

    $duration = $mov->getDuration();

    //we take the duration * the framerate to get an approx fram count (to make sure we dont go to high we take it * 0.9) also it needs to have more than 10 frames
    if(floor(($duration*0.9)*$framerate) > 10 && is_object($mov->getFrame(floor(($duration*0.9)*$framerate))))
    {
    $framecount = floor(($duration*0.9)*$framerate); //it worked we have a frame at duration * 0.9 * framerate, we're satisfied there even tho there possibly might be more frames
    }

    if(!isset($framecount) || $framecount <= 4 || !is_object($mov->getFrame($framecount-1))) //There should be a frame there, if there isnt the movie was lying about it's framrate or duration and we will have to start guessing frames.
    $framecount = -1;

    if($framecount < 0) //all has failed we will have to start guessing frames
    {
    $framecount = 1000; //lets guess at an approx of 30-50 second long movie
    while(!is_object($mov->getFrame($framecount))) //if we found a working frame we are happy and quits
    {
    $framecount = floor($framecount/2); //no working frame lets try half as many frames and see if it exists
    if($framecount < 10) //To few frames to be worth the bother ! (we probably cant read the file)
    exit("failure to read movie");
    }
    }
    }
    ----


    To put it easy it first checks that the frames exists and then tries to get a frame efter 20% of the movie, 40% and so on. There are multiple safety checks that should make sure that there are actually frames that I am trying to grab.

    I updated the ffmpeg using the method described here http://bytes.com/forum/thread716452.html
    but I did that yesterday and it didn't work before that either when I ran an earlier ffmpeg.

    I will write a small php file that just grabs one frame, will get back to you when it's done
    Quote Quote  
  6. Member
    Join Date
    Jul 2008
    Location
    Sweden
    Search Comp PM
    Here we are then, I wrote up a quick hack that just grabs a frame, any frame

    http://uare.mine.nu/rickardliljeberg/grabOneFrame.php?itemName=SDC10354.MP4&path=Files...8/Jul/&frame=2

    you see the last parameter is which frame you want, I can't get any to work

    however on an working video like this http://uare.mine.nu/rickardliljeberg/grabOneFrame.php?itemName=ice_melt_sound.avi&path.../Jul/&frame=78

    it all works like a charm.

    Is there anywhere errors are logged so I can see what error it reports

    btw the path to the wmv file is
    http://uare.mine.nu/rickardliljeberg/grabOneFrame.php?itemName=svensexa_warmup.wmv&pat...8/Jan/&frame=1
    Quote Quote  
  7. Get Slack disturbed1's Avatar
    Join Date
    Apr 2001
    Location
    init 4
    Search Comp PM
    Check your ffmpeg by doing this -
    Copy SDC10354.MP4 to your Home directory, open a terminal, copy and paste this in.
    ffmpeg -i SDC10354.MP4 -s 352x288 test.avi

    That's just an extremely simple command to attempt to encode the mp4 to a 352x288 avi file.

    If it fails to encode install the ffmpeg Ubuntu package from here -
    https://help.ubuntu.com/community/Medibuntu
    http://www.medibuntu.org/

    See if that helps.
    Linux _is_ user-friendly. It is not ignorant-friendly and idiot-friendly.
    Quote Quote  
  8. Member
    Join Date
    Jul 2008
    Location
    Sweden
    Search Comp PM
    [root@lyrd ~]# ffmpeg -i SDC10354.MP4 -s 352x288 test.avi
    FFmpeg version SVN-r14461, Copyright (c) 2000-2008 Fabrice Bellard, et al.
    configuration:
    libavutil version: 49.7.0
    libavcodec version: 51.62.0
    libavformat version: 52.18.0
    libavdevice version: 52.0.0
    built on Jul 28 2008 21:32:41, gcc: 3.4.4 20050721 (Red Hat 3.4.4-2)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SDC10354.MP4':
    Duration: 00:00:25.82, start: 0.000000, bitrate: 6725 kb/s
    Stream #0.0(und): Video: h264, yuv420p, 1280x720, 29.97 tb(r)
    Stream #0.1(und): Audio: mp4a / 0x6134706D, 48000 Hz, stereo
    Output #0, avi, to 'test.avi':
    Stream #0.0(und): Video: mpeg4, yuv420p, 352x288, q=2-31, 200 kb/s, 29.97 tb(c)
    Stream #0.1(und): Audio: mp2, 48000 Hz, stereo, 64 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0
    Stream #0.1 -> #0.1
    Unsupported codec (id=86018) for input stream #0.1


    That is what I get, can I run the ubuntu version on my old fedora?

    I'm off to the beach but I will be back in a few hours and if I can run that package I will install it then

    Thank you for all your help!

    //Rickard
    Quote Quote  
  9. Member
    Join Date
    Jul 2008
    Location
    Sweden
    Search Comp PM
    will the ffmpeg Ubuntu package work on an old fedora box?

    I sort of dont wanna mess things up

    //Rickard
    Quote Quote  
  10. Get Slack disturbed1's Avatar
    Join Date
    Apr 2001
    Location
    init 4
    Search Comp PM
    Originally Posted by lyrd
    will the ffmpeg Ubuntu package work on an old fedora box?

    I sort of dont wanna mess things up

    //Rickard
    Most likely not. I assumed you were using Ubuntu as that's what the distro was in the link you posted earlier. The Linva repo should have an uncrippled ffmpeg available. http://www.xades.com/proj/fedora_repos.html

    Your ffmpeg bails on the audio portion according to the error message above.
    Linux _is_ user-friendly. It is not ignorant-friendly and idiot-friendly.
    Quote Quote  
  11. Member
    Join Date
    Jul 2008
    Location
    Sweden
    Search Comp PM
    Excellent I will get right on that.

    Once again thanks for all the help!
    Quote Quote  
  12. Member
    Join Date
    Jul 2008
    Location
    Sweden
    Search Comp PM
    I am running Fedora Core release 3 (Heidelberg) which seems to be to old for linva :-\
    Quote Quote  
  13. Get Slack disturbed1's Avatar
    Join Date
    Apr 2001
    Location
    init 4
    Search Comp PM
    Release 3!!??!! That's quite old. Fedora is on release 9 now. Release 3 came out in 2004 and was declared end of life as of 2006. That means this release has not had a security update for 2 years. I hope this in not your web server. If it is I highly advise you to unplug it now. There were so many security vulernbilities between 2006 and now. Imagine installing Windows XP before SP 1 and never going to Windows Update to get any update/fix/hot fix. It's bad. Bad I tell you

    Even Fedora Legacy, which made an attempt to keep end of life Fedora releases up2date, shut down in 2007. And the last security update for FC 3 was listed on 2006-11-13.

    Update to a newer and more secure release. If you're worried about the instability of newer Fedora releases, but like the Red Hat way, check out www.centos.org, it is Red Hat Enterprise Linux with out the Red Hat branding or price. Red Hat (and it's clones like CentOS) tend to have a support life of ~5 years sometimes more.

    Debian stable has a good support life. Slackware is still pushing security updates for 8.1, which had a release date of 2002/06/18.
    Linux _is_ user-friendly. It is not ignorant-friendly and idiot-friendly.
    Quote Quote  
  14. Member
    Join Date
    Jul 2008
    Location
    Sweden
    Search Comp PM
    Hehe wow I never imagined stuff went ahead that fast, to be honest the machine is not used alot.

    It is a webserver but only second tier.
    I will however update it first chance I get.

    How come that when I downloaded and compiled the source straight from the svn it's still crippled since I can't fix the audio stream ?
    Quote Quote  
  15. Get Slack disturbed1's Avatar
    Join Date
    Apr 2001
    Location
    init 4
    Search Comp PM
    You maybe missing the optional binary codecs, such as FAAC and FAAD. By just doing ./configure and not passing any options, ffmpeg looks for what's installed and only configures for those codecs. Here's the configure I used -

    Code:
    ./configure \
      --prefix=/usr \
      --mandir=/usr/man \
      --disable-debug \
      --enable-shared \
      --disable-static \
      --enable-postproc \
      --enable-swscale \
      --enable-pthreads \
      --enable-liba52 \
      --enable-liba52bin \
      --enable-libfaac \
      --enable-libfaad \
      --enable-libfaadbin \
      --enable-libmp3lame \
      --enable-libtheora \
      --enable-libvorbis \
      --enable-libx264 \
      --enable-libxvid \
      --enable-gpl
    Prior to installing ffmpeg, I also compiled and installed NASM, YASM, lame, xvid, x264, liba52, faac, faad2, theora, and the ogg/vorbis libraries. Nasm and Yasm are assembly instructions that help xvid/lame (Nasm) and x264 (Yasm) perform faster. I only compiled my own, that way I could tune the CFLAGS and CXFLAGS for my cpu. Tuning does give me a slight speed up. Not much, but if you do a bit of encoding, those few fps surely add up over time.

    If the default pre-compiled binary packages are available for you, there's nothing wrong with using those instead.

    Here's the links for the different codecs needed to compile ffmpeg -
    xvid - http://www.xvid.org/Downloads.43.0.html (daily snapshot at the bottom)
    x264 - http://www.videolan.org/developers/x264.html
    liba52 - http://liba52.sourceforge.net/
    lame - http://sourceforge.net/project/showfiles.php?group_id=290
    faac/faad2 - http://sourceforge.net/project/showfiles.php?group_id=704
    libogg/vorbis/vorbis-tools/theora - http://xiph.org/downloads/
    nasm - http://sourceforge.net/project/showfiles.php?group_id=6208
    yasm - http://www.tortall.net/projects/yasm/wiki/Download

    If you decide to check out debian, everything above and then some is available at www.debian-multimedia.org
    Linux _is_ user-friendly. It is not ignorant-friendly and idiot-friendly.
    Quote Quote  
  16. Member
    Join Date
    Jul 2008
    Location
    Sweden
    Search Comp PM
    Excellent!

    I will still upgrade as soon as time allows, and after that I will get this to work
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!