LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Correcting wrong speed FLV videos? (https://www.linuxquestions.org/questions/linux-software-2/correcting-wrong-speed-flv-videos-689521/)

Steve W 12-10-2008 04:41 AM

Correcting wrong speed FLV videos?
 
Sometimes videos I watch/download on YouTube or similar have been encoded so that the video runs faster than the sound (i.e. the video is 2x speed, and the sound is normal speed, so they quickly become unsync'ed). It's only some videos, not all of them.

Is there software that will enable me to separate the sound and video of an FLV (or convert it to a different format where I can do this)?

I saw on the internet that Linux has a utility called "Mencoder".

(i) Would this do it?
(ii) Is there a better utility I should use instead?

Thank you for any advice you can give.

Steve

Shadow_7 12-11-2008 03:27 PM

There's ways to correct that in realtime with the player.

There's various formats out there. Europe types being PAL at 25 fps. Americas being NTSC at 30 fps. Blueray being 24 fps. TV being 60 fps interlaced. And other factors like aspect ratio.

mplayer -ao alsa -vo xv -fps 25 youtube.flv

otherwise:

ffmpeg -i source.flv -an -y video_only.flv
ffmpeg -i source.flv -vn -y audio_only.wav

or:

mplayer source.flv -dumpaudio -dumpfile audio_only.wav
mplayer source.flv -dumpvideo -dumpfile video_only.flv

And many many many other options. IME, most can be corrected in the player. Although not that useful if putting them on a dvd or other media type. -fps for mplayer. -monitoraspect or -aspect if you want to tweak the width/height relationships. As DVDs encode 720x480 (NTSC) video which can be either 16:9 or 4:3 (1.78 or 1.33) at playback. You can also use -vf scale -zoom -x 720 -y 540 (or 854x480) depending on how you want to deal with various quirks. Some of the technical specs are lost when encoding to various formats, so the player has to assume best guess. Which isn't always right.

HTH

Steve W 12-12-2008 09:16 AM

Wow - I didn't know you had that many options with mplayer. I shall try that out when I get home. I'll re-post to let you know how I got on.

I thought mplayer just let you play media files straight up, and that was that. I think some research on the web may be required into its full capabilities...

Steve

tredegar 12-12-2008 10:15 AM

Quote:

Wow - I didn't know you had that many options with mplayer.
That many?
You don't know the half of it: See man mplayer (when you have a weekend free).
There's not much it will not do, when asked nicely.

Steve W 12-12-2008 10:50 AM

One thing I have noticed, with Linux, is that after viewing a YouTube or similar Flash video, I can go into /tmp and copy it off to another folder, and keep it for viewing later in MPlayer. However, this file will not play on my Windows PC at work, even though it will play videos straight from youtube. I imagine Windows users must need separate software to allow them to play flash videos offline.

I wonder if one of the MPlayer options (when I get down to checking them out) will allow me to edit the video, in terms of saving just bits of it, like just the first 10 seconds, or last 2 minutes, that sort of thing...

Steve

tredegar 12-12-2008 11:00 AM

Linux has plenty of video editors, but none (that I am aware of) for FLashVideo.
Conversion to avi is easy though. Here's a little script:
Code:

#!/bin/sh
# Convert flash video to an avi
# See http://www.linux.com/articles/56642
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 \
        vcodec=mpeg4:vbitrate=$V_BITRATE:mbd=2:v4mv:autoaspect"
      ;;
    -xvid)
      MENC_OPTS="-ovc xvid -xvidencopts bitrate=$V_BITRATE:autoaspect"
      ;;
    *)
      if file "$1" | grep -q "Macromedia Flash Video"; then
        mencoder "$1" $MENC_OPTS -vf pp=lb -oac mp3lame \
          -lameopts fast:preset=standard -o \
          "`basename $1 .flv`.avi"
      else
        echo "$1 is not Flash Video. Skipping"
      fi
      ;;
  esac
  shift
done

It uses mencoder, from the same stable as mplayer, so, again, there are lots of options.

Steve W 12-13-2008 03:20 AM

Turns out, now I check, that I didn't have "mplayer" installed at all, so have never used it. The "Movie Player" I was using was actually Totem. So after a quick apt-get install, I have mplayer on my system.

Big long pause when I start it up, for some reason. Also, when I use the command line instruction suggested above to sync the video with the sound (turns out it needs to be 13.45 fps!), the mouse doesn't work for any playback options and the shell keeps popping up "No bind found for key 'MOUSE-BTN2' and such like, while the movie is playing.

Anyway, the best thing is for me to take a long, leisurely look at those man pages, and any other tutorials/help available online.

However, I have achieved my initial objective of synchronising video and sound on these problem videos, so thanks Shadow_7 and Tredegar for your advice and assistance.

Steve


All times are GMT -5. The time now is 01:00 PM.