Thursday, June 22, 2006

Ubuntu howto: converting .FLV to MPG


sudo apt-get install ffmpeg



ffmpeg -i video.flv -ab 56 -ar 22050 -b 500 -s 320x240 video.mpg

finally to make your life easier just put it a script file to excute later

mkdir ~/scripts;
echo 'ffmpeg -i $1 -ab 56 -ar 22050 -b 500 -s 320x240 $1.mpg' > f2mpg.sh;
mv Flv2Mpg.sh ~/scripts



now whenever you want to convert FLV file to mpg just shot the
 ~/scripts/f2mpg.sh Flv_video_file_name.flv


for further information check
man ffmpeg


[tags] ubuntu, linux, howto, convert, flv, mpg, avi, ffmpeg[/tags]

30 comments:

  1. Hey, thanks very much for this tip!!!

    ReplyDelete
  2. just what i need for converting files for my ppc. 10q man

    ReplyDelete
  3. gr8, never thought this was possible.

    ReplyDelete
  4. You can convert flv to mpeg easily useing Moyea Flash to Video Converter on windows.

    ReplyDelete
  5. I only get
    [flv @ 0x82c5740]Unsupported video codec (4)

    So, is there anyway to
    a) adjust your solution
    b) use another converting solution
    c) get totem, vlc or mplayer to play the file
    d) get another player to play the file

    all solutions must be for Linux of course, preferably Ubuntu...

    ReplyDelete
  6. Can you give yourself a name? and please paste the error here.
    maybe you should follow the instructions here.
    https://help.ubuntu.com/community/RestrictedFormats

    ReplyDelete
  7. Me = Larsson

    When I run f2mpg.sh I get
    >~/scripts/f2mpg.sh file.flv
    ffmpeg version CVS, build 3276800, Copyright (c) 2000-2004 Fabrice Bellard
    configuration: --build i486-linux-gnu --enable-gpl --enable-pp --enable-zlib --enable-vorbis --enable-libogg --enable-theora --enable-a52 --enable-dts --enable-dc1394 --enable-libgsm --disable-debug --prefix=/usr
    built on Sep 29 2005 03:25:16, gcc: 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)
    [flv @ 0x82c5740]Unsupported video codec (4)

    ReplyDelete
  8. Larsson,
    Weird, it should work; anyway please try
    file video.flv it should return
    video.flv: Macromedia Flash Video
    else it would be a different video format with incorrect .FLV extension

    actually I just tried to install ffmpeg on new ubuntu installation and I
    just had to install
    ffmpeg libdc1394-13 libimlib2 and it worked just fine


    ffmpeg -i video.flv -ab 56 -ar 22050 -b 500 -s 320x240 vide o.mpg
    ffmpeg version CVS, build 3276800, Copyright (c) 2000-2004 Fabrice Bellard
    configuration: --extra-cflags=-fomit-frame-pointer -DRUNTIME_CPUDETECT
    --buil d i486-linux-gnu --enable-gpl --enable-pp --enable-zlib
    --enable-vorbis
    --enable -libogg --enable-theora --enable-a52 --enable-dts --enable-dc1394
    --enable-libgs m --disable-debug --prefix=/usr

    built on Nov 24 2005 10:19:02, gcc: 4.0.3 20051121 (prerelease)
    (Ubuntu 4.0.2- 4ubuntu3)

    Seems that stream 1 comes from film source: 1000.00 (1000/1) -> 30.00 (30/1)
    Input #0, flv, from 'video.flv':
    Duration: N/A, bitrate: N/A
    Stream #0.0: Audio: mp3, 22050 Hz, mono
    Stream #0.1: Video: flv, yuv420p, 320x239, 1000.00 fps
    Output #0, mpeg, to 'video.mpg':
    Stream #0.0: Video: mpeg1video, yuv420p, 320x240, 30.00 fps, q=2-31, 500 kb/s
    Stream #0.1: Audio: mp2, 22050 Hz, mono, 56 kb/s
    Stream mapping:
    Stream #0.1 -> #0.0
    Stream #0.0 -> #0.1
    Press [q] to stop encoding
    frame= 922 q=0.0 Lsize= 2298kB time=30.5 bitrate= 617.0kbits/s
    video:2062kB audio:209kB global headers:0kB muxing overhead 1.213712%



    so finally if the file video.flv return a correct macromedia format then the solution would be beyond my experience how ever I'll try to digg for a solution

    ReplyDelete
  9. Link With Reality Web Log » links for 2006-07-06July 14, 2006 at 9:12 PM

    [...] Ubuntu howto: converting .FLV to MPG Quick tutorial on converting FLV files to MPG. (tags: howto video linux) Links :: John :: [...]

    ReplyDelete
  10. Hello,
    When I have tried to do this, I get this error string in root usr:

    root@jadesworld:/home/jadester# ffmpeg - vido.flv -ab 56 -ar 22050 -b 500 -s 320 x240 video.mpg
    ffmpeg version CVS, build 3276800, Copyright (c) 2000-2004 Fabrice Bellard
    configuration: --extra-cflags=-fomit-frame-pointer -DRUNTIME_CPUDETECT --buil d i486-linux-gnu --enable-gpl --enable-pp --enable-zlib --enable-vorbis --enable -libogg --enable-theora --enable-a52 --enable-dts --enable-dc1394 --enable-libgs m --disable-debug --prefix=/usr
    built on Nov 24 2005 10:19:02, gcc: 4.0.3 20051121 (prerelease) (Ubuntu 4.0.2- 4ubuntu3)
    Unable for find a suitable output format for 'pipe:'

    So I cannot convert flv files to mpg files. Help if you can. If you can't I totally understand.
    Any other info you may need pls ask. Thanks and Cheers!
    Jade

    ReplyDelete
  11. Quicksilver_JohnyJuly 15, 2006 at 10:59 AM

    On Xubuntu: with ffmpeg, libdc1394-13, and libimlib2:

    ffmpeg -i video.flv -ab 56 -ar 22050 -b 500 -s 320x240 video.mpg
    ffmpeg version CVS, build 3276800, Copyright (c) 2000-2004 Fabrice Bellard
    configuration: --extra-cflags=-fomit-frame-pointer -DRUNTIME_CPUDETECT --build i486-linux-gnu --enable-gpl --enable-pp --enable-zlib --enable-vorbis --enable-libogg --enable-theora --enable-a52 --enable-dts --enable-dc1394 --enable-libgsm --disable-debug --prefix=/usr
    built on Nov 24 2005 10:19:02, gcc: 4.0.3 20051121 (prerelease) (Ubuntu 4.0.2-4ubuntu3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    [flv @ 0x82c8200]Unsupported video codec (3)
    video.flv: could not find codec parameters

    ReplyDelete
  12. Jade,
    I'm not that expert but I found similar problem and solution at ffmpeg-user mailing list the guy had similar problem and they helped him to get it solved.


    Quicksilver_Johny,
    First go through this guide
    if it didn't work after installing the restricted format then it's not supported :(

    ReplyDelete
  13. [...] Sources: gillsmethod and jadmadi. tags: flv, youtube, saving youtube video, flv player, media coder, mplayer, ffmpeg [...]

    ReplyDelete
  14. do u know how to convert mpg videos to 3gp? using ffmpeg

    ReplyDelete
  15. Here's a small tweak for your script that cleans up the final filename a little:

    #!/bin/bash
    OLD=$1
    NEW=`basename $OLD .flv`
    ffmpeg -i $OLD -ab 56 -ar 22050 -b 500 -s 320x240 $NEW.mpg

    ReplyDelete
  16. Great work fella! Combine this with the firefox extension and you're laughing!
    http://javimoya.com/blog/youtube_en.php

    ReplyDelete
  17. Error:
    "mv Flv2Mpg.sh ~/scripts"
    should be
    "mv f2mpg.sh ~/scripts"
    right?

    ReplyDelete
  18. [mpeg1video @ 0x8336308]warning, clipping 1 dct coefficients to -255..255
    [mpeg1video @ 0x8336308]warning, clipping 1 dct coefficients to -255..255
    [mpeg1video @ 0x8336308]warning, clipping 1 dct coefficients to -255..255
    [mpeg1video @ 0x8336308]warning, clipping 1 dct coefficients to -255..255
    [mpeg1video @ 0x8336308]warning, clipping 1 dct coefficients to -255..255
    [mpeg1video @ 0x8336308]warning, clipping 1 dct coefficients to -255..255
    [mpeg1video @ 0x8336308]warning, clipping 1 dct coefficients to -255..255

    Why this happened?

    ReplyDelete
  19. hmm, well I don't know but I'll go through the documentations again and see if I can come up with a script that convert and give explanation when there is a problem.

    ReplyDelete
  20. [...] Ubuntu howto: converting .FLV to MPG (tags: flash howto kubuntu linux ubuntu video flv multimedia convert mpg) [...]

    ReplyDelete
  21. The Shout of Horus LeeSeptember 16, 2006 at 9:00 PM

    Ubuntu howto: converting .FLV to MPG by Jad...

    Ubuntu howto: converting .FLV to MPG by Jad...

    ReplyDelete
  22. Excellent!! That's exactly what i want...
    thnx.

    ReplyDelete
  23. Hey Jad, thanks for the cool tip, but after running the command, I get the following error:

    bijan@romanticFart:~$ ffmpeg -i MyDownloads/get_video.flv -ab 56 -ar 22050 -b 500 -s 320x240 oopse.mpg
    ffmpeg version CVS, build 3276800, Copyright (c) 2000-2004 Fabrice Bellard
    configuration: --extra-cflags=-fomit-frame-pointer -DRUNTIME_CPUDETECT --build i486-linux-gnu --enable-gpl --enable-pp --enable-zlib --enable-vorbis --enable-libogg --enable-theora --enable-a52 --enable-dts --enable-dc1394 --enable-libgsm --disable-debug --prefix=/usr
    built on Nov 24 2005 10:19:02, gcc: 4.0.3 20051121 (prerelease) (Ubuntu 4.0.2-4ubuntu3)

    Seems that stream 1 comes from film source: 1000.00 (1000/1) -> 15.00 (15/1)
    Input #0, flv, from 'MyDownloads/get_video.flv':
    Duration: N/A, bitrate: N/A
    Stream #0.0: Audio: mp3, 22050 Hz, mono
    Stream #0.1: Video: flv, yuv420p, 320x240, 1000.00 fps
    Output #0, mpeg, to 'oopse.mpg':
    Stream #0.0: Video: mpeg1video, yuv420p, 320x240, 15.00 fps, q=2-31, 500 kb/s
    Stream #0.1: Audio: mp2, 22050 Hz, mono, 56 kb/s
    Stream mapping:
    Stream #0.1 -> #0.0
    Stream #0.0 -> #0.1
    [mpeg1video @ 0x8336308]MPEG1/2 does not support 15/1 fps
    Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height



    Well, I have no idea what I should give for those parameters, any tips?

    ReplyDelete
  24. You may need to update your version of ffmpeg. I compile ffmpeg from source on ubuntu every so often. I use ffmpeg to convert youtube and google flash videos from to 3gp and mp4 clips on MyMobileClips

    ReplyDelete
  25. This is marvelous, thank you. One suggestion, if I may, though -- your script as-is fails on file names with spaces. A small modification fixes this:

    echo 'ffmpeg -i "$1" -ab 56 -ar 22050 -b 500 -s 320x240 "$1.mpg"' > f2mpg.sh

    Thank you so much for this excellent solution. I am most grateful!

    ReplyDelete
  26. here is my conversion script you can only do one video at a time
    the flv converts to mpg and keeps the original file name.


    #!/bin/bash


    output=`ls *.flv -1|cut -f1 -d"."`
    ffmpeg -i *.flv -ab 56 -ar 22050 -b 500 -s 320x240 $output.mpg
    rm *.flv
    exit

    ReplyDelete
  27. also you can only have one flv in the folder at a time
    you should put the script in /usr/bin make a folder just for converting video put a shortcut to the script(inside the folder) that runs in the terminal drag one flv into the folder and click your shortcut
    voila you have an mpg and the flv gets deleted. sorry for 2 post just wanted to make it easy on someone else.Took a while to get this right i'm not a bash expert.

    ReplyDelete
  28. Why not simply add a command to your .bashrc instead of making a script?

    ReplyDelete

  29. dice@ZepplinIV:~$ ffmpeg -i video.flv -ab 56 -ar 22050 -b 500 -s 320x240 video.mpg
    FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2004 Fabrice Bellard
    configuration: --enable-gpl --enable-pp --enable-pthreads --enable-vorbis --enable-libogg --enable-a52 --enable-dts --enable-libgsm --enable-dc1394 --disable-debug --enable-shared --prefix=/usr
    libavutil version: 0d.49.0.0
    libavcodec version: 0d.51.11.0
    libavformat version: 0d.50.5.0
    built on Jan 28 2007 22:48:38, gcc: 4.1.2 20070106 (prerelease) (Ubuntu 4.1.1-21ubuntu7)
    video.flv: I/O error occured
    Usually that means that input file is truncated and/or corrupted


    I'm pretty new to linux, however I'm pretty sure the video works, because I can play it in windows on divX. Do you know if there would be any problem?
    P.S. I'm using Feisty, but I figured it wouldn't be a problem.

    ReplyDelete
  30. John
    I'd recommend using PyTube

    sudo aptitude install pytube

    ReplyDelete