LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 06-04-2008, 02:20 AM   #1
btbx
Member
 
Registered: Jun 2007
Posts: 67

Rep: Reputation: 15
Question Converting flv to Mpg with Audio and ffmpeg


I try to conver flv files to ordinary mpg with ffmpeg.
I try many audio options including bitrate, sampling, audio channel,
but the result is no audio at all / silent.
The picture is OK

What is the best software for converting flv movies to mpg?

What is the best parameter for ffmpeg that will work 100%?

Thank you.
 
Old 06-04-2008, 07:28 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
There is no 100% solution when it comes to multimedia because there are too many variables to consider. What may work on one file can easily fail on another with only slightly different parameters.

At a first guess, I'd say it's probably a codec problem. You may need to install a separate audio decoder or get/recompile a version of ffmpeg with different codec support. Try running "ffplay file.flv" to see if ffmpeg can decode file normally.

Anyway, how about showing us the command(s) you've tried and what output you get. And is this true of all flv files or just a few? Have you tried the same processes on other types of files such as an avi or mpeg?
 
Old 06-04-2008, 04:20 PM   #3
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,173

Rep: Reputation: 47
I have a script I found to convert flv to avi. When I first tried it I missed the avifix command and was getting the same result of video without audio. You could probably use this and modify or add to it to change the avi to mpg. Hope this helps.

Code:
#!/bin/sh

if [ $# = 0 ]; then
echo "Usage: flv2avi file.flv"
exit 1
fi

#Convert to avi with stereo 48K sound
OUT=$1.avi
ffmpeg  -i $1 -ar 48000 -ac 2 $OUT
avifix -i $OUT -F DX50

exit 1
 
Old 06-05-2008, 12:47 AM   #4
btbx
Member
 
Registered: Jun 2007
Posts: 67

Original Poster
Rep: Reputation: 15
Question

Thank you for all answers.

All example online from google use ffmpeg with kbits as parameter, not bits with erronous result.

example ffmpeg -ab 56, when it should be ffmpeg -ab 56000

I had created a general purpose 1 line script:

Content flv2mpg.sh

ffmpeg -i $1.flv -ab 128000 -ar 44100 -b 500000 -s 640x480 -ac 2 -acodec libmp3lame $1.mpg


-ab parameter: audio bitrate. Other: 56000, 80000, 256000
-ar parameter: audio sampling rate (Hz). Other: 22050
-b parameter: bitrate: 500000: high bitrate may reduce "Pixelated" effect".
-s parameter: screen resolution. Other: 320x200
-ac parameter: number of audio channel. Other: 1 (mono)
2 (stereo).
-acodec parameter: audio codec.

Before using the script make sure ffmpeg is compiled with built-in libmp3lame. You must install / compile lame first before compiling ffmpeg.

Present problems:
File name after -i cannot contain space or "-" (minus) character. Example:

flv2mpg "Lionel Richie---Hello.flv" will produce error.
I had to rename the file to "richiehello.flv"
After the conversion I had to rename the result from
"richiehello.mpg" to "Lionel Richie---Hello.mpg"

Is it possible to modify the script to enable it to accept space and "-" (minus) character?

Thank you.

Last edited by btbx; 06-12-2008 at 11:51 PM.
 
Old 06-05-2008, 02:26 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
About a year or so ago the ffmpeg project changed their command argument requirements a bit, and one of the things they changed was to require -b and -ab to be in bits. This is why most older examples are wrong. You can easily fix them by simply adding 'k' to the bitrate numbers; e.g. "-b 48k".

But now I don't understand. Your second post has nothing to do with the problem you expressed in the first. Did you manage to get the audio working? Was it just because of the inaccurate bitrate problem?

As for your script, you have to put quotes around the whole filename in order to ensure that it is read as a unit. This is true for the command line and also true for any $# outputs in the script itself. So simply put quotes around the "$1" entries.

Code:
#!/bin/bash

ffmpeg -i "$1".flv -ab 128000 -ar 44100 -b 200000 -s 640x480 -ac 2 -acodec libmp3lame "$1".mpg
That should let it work. Though to tell the truth, it's good practice to avoid spaces and illegal characters in filenames anyway. They're such a headache to work around. I personally try to keep most of my files in lower-case, with spaces changed to underscores and odd characters kept to a minimum. It saves me a lot of hassle that way.

Last edited by David the H.; 06-05-2008 at 02:27 AM.
 
Old 06-06-2008, 06:48 AM   #6
btbx
Member
 
Registered: Jun 2007
Posts: 67

Original Poster
Rep: Reputation: 15
Smile

Thank you for the explanation and correction.

I found another flv to mpg converter script on google using mencoder.

Unfortunately I cannot find the correct parameter.

The audio stutter (stop and go) and cannot be used at all.
The video is OK.

Any idea how to use mencoder for converting flv to mpg?
Thank you.
 
Old 06-07-2008, 06:37 PM   #7
btbx
Member
 
Registered: Jun 2007
Posts: 67

Original Poster
Rep: Reputation: 15
Exclamation

After several days of battle with mencoder parameters, I created 2 reliable scripts in turning flv videos to mpg with libmp3lame (mp3) and flv to avi with twolame (mp2).

Is there any other possible correction / improvement of the script?
The stuttering audio (stop and go) is because the default bit rate is too high. I use 64 and 56.

Content of flv2mpg script:

mencoder "$1" -mc 0 -noskip -vf harddup -oac lavc -lavcopts acodec=libmp3lame:abitrate=64 -ovc lavc -o "$1".mpg

Content of flv2avi script:

mencoder "$1" -mc 0 -noskip -vf harddup -oac twolame -twolameopts br=56 -ovc lavc -o "$1".avi

Last edited by btbx; 06-07-2008 at 06:39 PM.
 
Old 06-12-2008, 02:41 PM   #8
btbx
Member
 
Registered: Jun 2007
Posts: 67

Original Poster
Rep: Reputation: 15
Smile

The above script flv2mpg.sh produce file with FMP4 (MPEG4 ISO / DIVX 5) standard codec.

Unfortunately some media player device, picture frame that support MP4 actually use
older standards of MPEG4: mspeg4 or msmpeg4v2.

To create video file with old standard:

flv2oldmpeg4.sh

mencoder "$1" -mc 0 -noskip -vf harddup -oac mp3lame -lameopts preset=64:mode=0:vol=10:cbr -ovc lavc -lavcopts vcodec=msmpeg4v2:vpass=1 -o "$1".mpg

...Or....

mencoder "$1" -mc 0 -noskip -vf harddup -oac mp3lame -lameopts preset=64:mode=0:vol=10:cbr -ovc lavc -lavcopts vcodec=msmpeg4:vpass=1 -o "$1".mpg

Audio setting: 64 bit constant bit rate, with 10 volume gain and stereo mode.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you split mpg files using a ffmpeg command? milkjerry3 Linux - Newbie 19 05-12-2011 08:09 AM
Conversion of mpg,avi,mov,wmv formats to flv manu82 Linux - Software 6 07-30-2008 04:31 AM
LXer: Convert .flv (Google Videos) to .mpg using ffmpeg LXer Syndicated Linux News 0 07-25-2007 06:31 AM
ffmpeg on slack 10.2 wmv to mpg Pier Slackware 2 01-05-2006 04:39 PM
how do i convert wmv to flv using ffmpeg? farmerjoe Linux - Software 0 11-15-2005 02:20 PM


All times are GMT -5. The time now is 07:58 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration