anyone know their way around with ffmpeg?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JamesK
    hi
    • Jun 2002
    • 16731

    #1

    anyone know their way around with ffmpeg?

    I need a php file that automatically grabs a screen cap of the first second of a flv video, using ffmpeg. I want to be able to use it in LongTail Video's flash player.

    Anyone know how to do this?
    M3Server - NATS Hosting
  • JamesK
    hi
    • Jun 2002
    • 16731

    #2
    this bitch dropped fast
    M3Server - NATS Hosting

    Comment

    • polish_aristocrat
      Too lazy to set a custom title
      • Jul 2002
      • 40377

      #3
      Originally posted by JamesK
      this bitch dropped fast
      that's because only 3.75% of GFY'ers know what you're talking about
      I don't use ICQ anymore.

      Comment

      • stevo
        Confirmed User
        • Aug 2002
        • 2051

        #4
        Maybe this php file will work for you:
        http://sourceforge.net/project/showf...roup_id=122353

        ffmpeg-php is an extension for PHP that adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. It has methods for returning frames from movie files as images that can be manipulated using PHP's image functions. This works well for automatically creating thumbnail images from movies. ffmpeg-php is also useful for reporting the duration and bitrate of audio files (mp3, wma...). ffmpeg-php can access many of the video formats supported by ffmpeg (mov, avi, mpg, wmv...)

        Comment

        • HorseShit
          Too lazy to set a custom title
          • Dec 2004
          • 17513

          #5
          If you're using LongTail I will have to assume you took my advice

          Comment

          • JamesK
            hi
            • Jun 2002
            • 16731

            #6
            Originally posted by Justin
            If you're using LongTail I will have to assume you took my advice
            Yep, I knew about the player and used it before but with the AdSolution plugin it really does everything I need it to do
            M3Server - NATS Hosting

            Comment

            • Tube Ace
              So Fucking Banned
              • Nov 2008
              • 4941

              #7
              http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html

              For extracting images from a video:

              ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg

              This will extract one video frame per second from the video and will output them in files named `foo-001.jpeg', `foo-002.jpeg', etc. Images will be rescaled to fit the new WxH values.

              If you want to extract just a limited number of frames, you can use the above command in combination with the -vframes or -t option, or in combination with -ss to start extracting from a certain point in time.

              Comment

              • AdultSoftwareSolutions
                Confirmed User
                • Mar 2009
                • 193

                #8
                Google is your friend.
                Adult Software Solutions (ICQ 559884738)
                PHP, MySQL, Flash, Actionscript, Java, Wowza, CMS, Tube, VOD, CRM, Dating, Social Networks, Paysites, TGPs, Directories and more.
                If you can think it I can build it.

                Comment

                • fris
                  I have to go potty
                  • Aug 2002
                  • 55792

                  #9
                  prob only like 5 lines of code
                  Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                  My Newest Theme

                  Comment

                  • Killswitch - BANNED FOR LIFE

                    #10
                    Originally posted by stevo
                    Maybe this php file will work for you:
                    http://sourceforge.net/project/showf...roup_id=122353

                    ffmpeg-php is an extension for PHP that adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. It has methods for returning frames from movie files as images that can be manipulated using PHP's image functions. This works well for automatically creating thumbnail images from movies. ffmpeg-php is also useful for reporting the duration and bitrate of audio files (mp3, wma...). ffmpeg-php can access many of the video formats supported by ffmpeg (mov, avi, mpg, wmv...)

                    Comment

                    • SmokeyTheBear
                      ►SouthOfHeaven
                      • Jun 2004
                      • 28609

                      #11
                      <?php
                      echo exec("/usr/local/bin/ffmpeg -i /home/account/public_html/video/video.flv -an -ss 1 -t 00:00:01 -r 1 -y -s qcif -f mjpeg /home/account/public_html/snapshot/snapshot.jpg");
                      ?>
                      Last edited by SmokeyTheBear; 05-19-2009, 02:43 PM.
                      hatisblack at yahoo.com

                      Comment

                      • Chris
                        Too lazy to set a custom title
                        • May 2003
                        • 27880

                        #12
                        i thought this was about the mac program ffmpegX that i use to convert my avi's to mov for my apple tv ;x
                        [email protected]

                        Comment

                        • SmokeyTheBear
                          ►SouthOfHeaven
                          • Jun 2004
                          • 28609

                          #13
                          Originally posted by SmokeyTheBear
                          <?php
                          echo exec("/usr/local/bin/ffmpeg -i /home/account/public_html/video/video.flv -an -ss 1 -t 00:00:01 -r 1 -y -s qcif -f mjpeg /home/account/public_html/snapshot/snapshot.jpg");
                          ?>
                          if you want to do every flv in a directory at once try this
                          <?php
                          foreach (glob("*.flv") as $filename) {
                          echo exec("/usr/local/bin/ffmpeg -i /home/account/public_html/video/$filename -an -ss 1 -t 00:00:01 -r 1 -y -s qcif -f mjpeg /home/account/public_html/snapshot/$filename.jpg");

                          }

                          ?>

                          drop the php file in the folder with the flv's

                          p.s. change the paths to your paths of course
                          hatisblack at yahoo.com

                          Comment

                          • SmokeyTheBear
                            ►SouthOfHeaven
                            • Jun 2004
                            • 28609

                            #14
                            Originally posted by Chris
                            i thought this was about the mac program ffmpegX that i use to convert my avi's to mov for my apple tv ;x
                            ffmpegx includes ffmpeg so yes
                            hatisblack at yahoo.com

                            Comment

                            • fris
                              I have to go potty
                              • Aug 2002
                              • 55792

                              #15
                              Originally posted by JamesK
                              I need a php file that automatically grabs a screen cap of the first second of a flv video, using ffmpeg. I want to be able to use it in LongTail Video's flash player.

                              Anyone know how to do this?
                              this is really rough, prob could be done better but.

                              Code:
                              <?
                              $video = $_GET['f'];
                              $movie = new ffmpeg_movie($video, false);
                              $frames = $movie->getFrameCount();
                              $frame = $movie->getFrame(50);
                              $im = $frame->toGDImage();
                              imagejpeg($im,"$video.jpg");
                              imagedestroy($im);
                              header("Content-type:image/jpeg");
                              readfile("$video.jpg");
                              ?>
                              then call it via a flashvar

                              Code:
                              so.addVariable("image", "imgflv.php?f=video.flv");
                              you get the idea.
                              Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                              My Newest Theme

                              Comment

                              • fris
                                I have to go potty
                                • Aug 2002
                                • 55792

                                #16
                                Originally posted by SmokeyTheBear
                                if you want to do every flv in a directory at once try this
                                <?php
                                foreach (glob("*.flv") as $filename) {
                                echo exec("/usr/local/bin/ffmpeg -i /home/account/public_html/video/$filename -an -ss 1 -t 00:00:01 -r 1 -y -s qcif -f mjpeg /home/account/public_html/snapshot/$filename.jpg");

                                }

                                ?>

                                drop the php file in the folder with the flv's

                                p.s. change the paths to your paths of course
                                he wants it to do it via the flash player, that will do a directory.

                                plus you could do it easier via a shell script

                                Code:
                                for i in *.flv; do ffmpeg -an -y -t 00:00:01 -i "$i" -f image2 "`echo $i |sed 's/.flv$/.jpg/'`" ;done
                                Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                                My Newest Theme

                                Comment

                                • Chris
                                  Too lazy to set a custom title
                                  • May 2003
                                  • 27880

                                  #17
                                  this thread gave me a headache but i keep staring at fris' avatar


                                  mmmmmmm
                                  [email protected]

                                  Comment

                                  • Killswitch - BANNED FOR LIFE

                                    #18
                                    Originally posted by fris
                                    this is really rough, prob could be done better but.

                                    Code:
                                    <?
                                    $movie = new ffmpeg_movie($_GET['f'], false);
                                    $frame = $movie->getFrame(50);
                                    $im = $frame->toGDImage();
                                    header('Content-type:image/jpeg');
                                    imagejpeg($im);
                                    imagedestroy($im);
                                    ?>
                                    then call it via a flashvar

                                    Code:
                                    so.addVariable("image", "imgflv.php?f=video.flv");
                                    you get the idea.
                                    I cleaned it up for you.

                                    Comment

                                    • JamesK
                                      hi
                                      • Jun 2002
                                      • 16731

                                      #19
                                      Wow, thanks a lot guys! Didn't expect so much input.

                                      I'll test it out asap and let you know if it worked and share the whole solution.
                                      M3Server - NATS Hosting

                                      Comment

                                      • JamesK
                                        hi
                                        • Jun 2002
                                        • 16731

                                        #20
                                        Ok sweet it works like a charm! Here's a recap of the whole situation & solution for those with the same problem:

                                        Since LongTail's FLV player does not automaticallly create a preview on the actual video page I had two choices, either enable autoplay so no preview is required, or use a little ffmpeg php script to make a screen cap of the video. The second seemed like a better option to save a lot of bandwidth (it's still user friendly since he only has to click a big ass play button to start the video).

                                        I installed FFMPEG and FFMPEG-PHP (not sure if I needed both but whatever they're both on my server here now. Here are the tutorials for Linux:

                                        FFMPEG tutorial: http://www.mysql-apache-php.com/ffmpeg-install.htm
                                        FFMPEG-PHP tutorial: http://ffmpeg-php.sourceforge.net/

                                        I made a PHP file (thanks Fris & Killswitch) called imgpreview.php and added this code to it.

                                        Code:
                                        <?
                                        $movie = new ffmpeg_movie($_GET['f'], false);
                                        $frame = $movie->getFrame(50);
                                        $im = $frame->toGDImage();
                                        header('Content-type:image/jpeg');
                                        imagejpeg($im);
                                        imagedestroy($im);
                                        ?>
                                        And added image=imgpreview.php?f=videofile.flv to the flashvars. If you're using TubeAce like me, you should replace videofile.flv to {video_file} and you're set!

                                        Thanks again guys.
                                        M3Server - NATS Hosting

                                        Comment

                                        • wizzart
                                          scriptmaster
                                          • May 2006
                                          • 5246

                                          #21
                                          Anytime ;)
                                          BimboZone

                                          Comment

                                          • wizzart
                                            scriptmaster
                                            • May 2006
                                            • 5246

                                            #22
                                            LoL LoL
                                            BimboZone

                                            Comment

                                            • nation-x
                                              Confirmed User
                                              • Mar 2004
                                              • 5370

                                              #23
                                              Code:
                                              function grabScreen($clip, $thumb, $dimensions) {
                                                  //$dimensions should be in WxH format
                                                  //$thumb should contain the full path to the image you want created
                                                  $screengrab = "/usr/local/bin/ffmpeg -y -i '{$clip}' -f mjpeg -ss 10 -vframes 1 -s {$dimensions} -an '{$thumb}'";
                                                  @system($screengrab);
                                              }
                                              Last edited by nation-x; 05-20-2009, 05:57 AM.

                                              Comment

                                              • CaptainHowdy
                                                Too lazy to set a custom title
                                                • Dec 2004
                                                • 94113

                                                #24
                                                Smokey hitted it...

                                                Comment

                                                • fris
                                                  I have to go potty
                                                  • Aug 2002
                                                  • 55792

                                                  #25
                                                  Originally posted by nation-x
                                                  Code:
                                                  function grabScreen($clip, $thumb, $dimensions) {
                                                      //$dimensions should be in WxH format
                                                      //$thumb should contain the full path to the image you want created
                                                      $screengrab = "/usr/local/bin/ffmpeg -y -i '{$clip}' -f mjpeg -ss 10 -vframes 1 -s {$dimensions} -an '{$thumb}'";
                                                      @system($screengrab);
                                                  }
                                                  whats the difference between using ffmpeg executable and the php module?
                                                  Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                                                  My Newest Theme

                                                  Comment

                                                  • Killswitch - BANNED FOR LIFE

                                                    #26
                                                    Originally posted by JamesK
                                                    Ok sweet it works like a charm! Here's a recap of the whole situation & solution for those with the same problem:

                                                    Since LongTail's FLV player does not automaticallly create a preview on the actual video page I had two choices, either enable autoplay so no preview is required, or use a little ffmpeg php script to make a screen cap of the video. The second seemed like a better option to save a lot of bandwidth (it's still user friendly since he only has to click a big ass play button to start the video).

                                                    I installed FFMPEG and FFMPEG-PHP (not sure if I needed both but whatever they're both on my server here now. Here are the tutorials for Linux:

                                                    FFMPEG tutorial: http://www.mysql-apache-php.com/ffmpeg-install.htm
                                                    FFMPEG-PHP tutorial: http://ffmpeg-php.sourceforge.net/

                                                    I made a PHP file (thanks Fris & Killswitch) called imgpreview.php and added this code to it.

                                                    Code:
                                                    <?
                                                    $movie = new ffmpeg_movie($_GET['f'], false);
                                                    $frame = $movie->getFrame(50);
                                                    $im = $frame->toGDImage();
                                                    header('Content-type:image/jpeg');
                                                    imagejpeg($im);
                                                    imagedestroy($im);
                                                    ?>
                                                    And added image=imgpreview.php?f=videofile.flv to the flashvars. If you're using TubeAce like me, you should replace videofile.flv to {video_file} and you're set!

                                                    Thanks again guys.
                                                    If you wanna make it more random, say just a random frame from the video, you can do this...

                                                    Code:
                                                    <?
                                                    $movie = new ffmpeg_movie($_GET['f'], false);
                                                    $frame = $movie->getFrame(rand(1, getFrameCount());
                                                    $im = $frame->toGDImage();
                                                    header('Content-type:image/jpeg');
                                                    imagejpeg($im);
                                                    imagedestroy($im);
                                                    ?>

                                                    Comment

                                                    • SmokeyTheBear
                                                      ►SouthOfHeaven
                                                      • Jun 2004
                                                      • 28609

                                                      #27
                                                      guess i misunderstood the question, sorry i attempted to help you. i'll just keep me trap shut next time
                                                      hatisblack at yahoo.com

                                                      Comment

                                                      • JamesK
                                                        hi
                                                        • Jun 2002
                                                        • 16731

                                                        #28
                                                        Originally posted by Killswitch
                                                        If you wanna make it more random, say just a random frame from the video, you can do this...

                                                        Code:
                                                        <?
                                                        $movie = new ffmpeg_movie($_GET['f'], false);
                                                        $frame = $movie->getFrame(rand(1, getFrameCount());
                                                        $im = $frame->toGDImage();
                                                        header('Content-type:image/jpeg');
                                                        imagejpeg($im);
                                                        imagedestroy($im);
                                                        ?>
                                                        Thanks bud, that'll come in handy

                                                        Originally posted by SmokeyTheBear
                                                        i'll just keep me trap shut next time
                                                        Please don't, I love you too
                                                        M3Server - NATS Hosting

                                                        Comment

                                                        Working...