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-24-2012, 09:39 AM   #1
Steve W
Member
 
Registered: Mar 2007
Distribution: Ubuntu 12.04, Mint 12 LXDE
Posts: 440

Rep: Reputation: 36
flv to avi converter - syncing problems


For a while now I have been using a script I found to convert flv files (such as downloaded from YouTube) to avi. The script I use is:

Code:
#!/bin/sh

if [ -z "$1" ]; then
  echo "Usage: $0 {-divx|-xvid} list_of_flv_files"
  exit 1
fi
# video encoding bit rate
V_BITRATE=1000

while [ "$1" ]; do
  case "$1" in
    -divx)
      MENC_OPTS="-ovc lavc -lavcopts -vf harddup \
        vcodec=mpeg4:vbitrate=$V_BITRATE:mbd=2:v4mv:autoaspect"
      ;;
    -xvid)
      MENC_OPTS="-ovc xvid -vf harddup -xvidencopts bitrate=$V_BITRATE:autoaspect"
      ;;
    *)
      if file "$1" | grep -q "Macromedia Flash Video"; then
        mencoder "$1" $MENC_OPTS -vf pp=lb -oac mp3lame -vf harddup \
          -lameopts fast:preset=standard -o \
          "`basename $1 .flv`.avi"
      else
        echo "$1 is not Flash Video. Skipping"
      fi
      ;;
  esac
  shift
done
Initially, I had a problem with some files losing sync between video and audio. So people's lips didn't always keep track with what they were saying. So after Googling the problem, I added the -vf harddup option to the mencoder line - it wasn't there before.

Apparently the problem can be caused by mencoder dropping frames occasionally. Option harddup is meant to stop this from happening.

Except I still get sync problems even with this amended script. Can anyone with a knowledge of mencoder see why? Should I put the -vf option in a different place within the command line, or would anywhere do? Is there anything else I can try, to preserve synchronicity while converting from flv to avi?

Last edited by Steve W; 06-24-2012 at 09:41 AM.
 
Old 06-24-2012, 12:41 PM   #2
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,758

Rep: Reputation: Disabled
download with youtube-dl with all fancy options (prefer webm)
If flv, then convert with ffmpeg
<code>
for I in *.flv; do ffmpeg -i "$I" -sameq "${I%.flv}.avi"; done
</code>
 
Old 06-25-2012, 04:13 AM   #3
Steve W
Member
 
Registered: Mar 2007
Distribution: Ubuntu 12.04, Mint 12 LXDE
Posts: 440

Original Poster
Rep: Reputation: 36
Thanks, but your line does not encode to xvid, which is the only format that will play on my DVD player (it has a USB port in the front to play videos from a memory stick, but formats it will play are limited).

I tried to add an xvid option to your line, but it did not work:

for I in *.flv; do ffmpeg -i "$I" -vcodec xvid -sameq "${I%.flv}.avi"; done

It says "Unknown encoder - xvid", despite me getting the option from a webpage of ffmpeg options! Is there something I need to download to add to the standard ffmpeg package to give it xvid conversion capabilities, or can you suggest another ffmpeg argument that would convert to xvid?
 
Old 06-25-2012, 04:53 AM   #4
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 609

Rep: Reputation: 180Reputation: 180
Quote:
Originally Posted by Steve W View Post
It says "Unknown encoder - xvid", despite me getting the option from a webpage of ffmpeg options! Is there something I need to download to add to the standard ffmpeg package to give it xvid conversion capabilities, or can you suggest another ffmpeg argument that would convert to xvid?
It depends on how your ffmpeg version has been compiled from source, as you need to specify a configure-time option to compile-in support to the xvidcore library.
 
Old 06-25-2012, 05:10 AM   #5
Steve W
Member
 
Registered: Mar 2007
Distribution: Ubuntu 12.04, Mint 12 LXDE
Posts: 440

Original Poster
Rep: Reputation: 36
I've never compiled anything from source. I'm one of those who download everything from the Ubuntu Software Centre.

So, if ffmpeg's not gonna work for me then - anyone got any other suggestions (maybe using mencoder or Avidemux)? The option on YouTube Downloader for converting seems to downgrade the quality of the video sound (from 44K to 22K) and there are no options in that program to change this. So I can't use that.

Thank you for your patience.
 
Old 06-25-2012, 08:41 AM   #6
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 609

Rep: Reputation: 180Reputation: 180
Quote:
Originally Posted by Steve W View Post
I've never compiled anything from source. I'm one of those who download everything from the Ubuntu Software Centre.

So, if ffmpeg's not gonna work for me then - anyone got any other suggestions (maybe using mencoder or Avidemux)?
Do not give up so easily. Turns out that ffmpeg expects libxvid instead of xvid as a vcodec option, so you should be able to use it.
Take note, however, that you'll probably need to tweak video encoding options.
 
Old 06-25-2012, 10:00 PM   #7
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 1,773

Rep: Reputation: 197Reputation: 197
Try -vf softskip instead of harddup

Also look at delay

http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html
 
Old 06-26-2012, 05:47 AM   #8
Steve W
Member
 
Registered: Mar 2007
Distribution: Ubuntu 12.04, Mint 12 LXDE
Posts: 440

Original Poster
Rep: Reputation: 36
Okay, I'll give both of those a go. Thanks.
 
Old 06-26-2012, 01:58 PM   #9
Steve W
Member
 
Registered: Mar 2007
Distribution: Ubuntu 12.04, Mint 12 LXDE
Posts: 440

Original Poster
Rep: Reputation: 36
I should point out, that when I use the script above (the longer one with Mencoder), the output constantly reports "Skipping frame" at numerous intervals while converting. I don't know whether the softskip or harddup options are meant to either stop that from happening, or negate its influence - but I wondered whether all that frame skipping is the reason the AV gets out of sync....
 
  


Reply

Tags
avi, convert, flv, mencoder, sync


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
converting multiple flv to avi.. mia_tech Linux - General 2 10-15-2008 02:52 PM
Free FLV to MP3 Converter igosurfing Programming 1 07-14-2008 06:29 AM


All times are GMT -5. The time now is 05:46 PM.

Main Menu
Advertisement
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