LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 02-15-2013, 10:53 AM   #1
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
DVD/HD Recorder can’t play AVI file


The problem described below affects my DVD/HD Recorder and some AVI file. I put my query into LQ Software section because I try to find the method to encode the mentioned file anew in order to made it acceptable for my recorder device.

***

I own LG RH387 Recorder. It accepts USB Flash Drives including different content. Usually I use it to watch the movies.

The device understands the following formats:

● Video: DIV3, MP43, DIVX, DX50
● Audio: AC3, PCM, MP2, MP3, WMA

Yesterday I found some movie file in AVI format causing the serious problems with my recorder device.

1st scenario

When I try to play the original file:

movie.avi

device doesn’t open the file but displays the message: “Can’t Playable. Unknown Video Format.”.

2nd scenario

I used mencoder to simply copy that file to the 5 minutes long sample:

Code:
mencoder movie.avi -ovc copy -oac copy -endpos 300 -o 0300.avi
When I try to play the file:

0300.avi

device opens the file and plays it all (5 minutes).

Then I used mencoder to copy that file to the 1 hour long sample:

Code:
mencoder movie.avi -ovc copy -oac copy -endpos 3600 -o 3600.avi
When I try to play the file:

3600.avi

device opens the file and plays it all (1 hour).

Next I used mencoder to copy that file to the 2.5 hour long sample:

Code:
mencoder movie.avi -ovc copy -oac copy -endpos 9000 -o 9000.avi
When I try to play the file:

9000.avi

device doesn’t open the file but displays the message: “Can’t Playable. Unknown Video Format.” (the same as appearing with the original movie.avi file).

So it looks like there’s some bug in the original movie.avi file between 1 hour and 2.5 hours that causes the described problem and mencoder used with copy+copy options copies that bug.

3rd scenario

Then I decided to try to encode 0300.avi sample file anew using mencoder:

Code:
mencoder 0300.avi -ovc lavc -oac copy    -o 0300-mencoder-lavc+copy.avi
mencoder 0300.avi -ovc lavc -oac mp3lame -o 0300-mencoder-lavc+mp3lame.avi
mencoder 0300.avi -ovc lavc -oac pcm     -o 0300-mencoder-lavc+pcm.avi
When I try to play the files:

0300-mencoder-lavc+copy.avi
0300-mencoder-lavc+mp3lame.avi
0300-mencoder-lavc+pcm.avi

device doesn’t open none file but displays the message: “Can’t Playable. Not Supported Video Codec.”.

Apparently mencoder lavc option generates the format unacceptable by the device.

4th scenario

Next I decided to try to encode 0300.avi sample file anew using ffmpeg:

Code:
ffmpeg -i 0300.avi -c:v libxvid          -qscale:v 3 -c:a libmp3lame -qscale:a 4 0300-ffmpeg-libxvid.avi
ffmpeg -i 0300.avi -c:v mpeg4 -vtag xvid -qscale:v 3 -c:a libmp3lame -qscale:a 4 0300-ffmpeg-mpeg4.avi
ffmpeg -i 0300.avi -c:v msmpeg4          -qscale:v 3 -c:a libmp3lame -qscale:a 4 0300-ffmpeg-msmpeg4.avi
When I try to play the files:

0300-ffmpeg-libxvid.avi
0300-ffmpeg-mpeg4.avi
0300-ffmpeg-msmpeg4.avi

device opens each file but doesn’t play them at all (the screen is black and the counter displays: 00:00:00).

It seems ffmpeg produces the output unacceptable by the device.

5th scenario

Finally I decided to try to encode the sample files produced by ffmpeg using mencoder:

Code:
mencoder 0300-ffmpeg-libxvid.avi -ovc copy -oac copy -o 0300-ffmpeg-libxvid-mencoder-copy+copy.avi
mencoder 0300-ffmpeg-mpeg4.avi   -ovc copy -oac copy -o 0300-ffmpeg-mpeg4-mencoder-copy+copy.avi
mencoder 0300-ffmpeg-msmpeg4.avi -ovc copy -oac copy -o 0300-ffmpeg-msmpeg4-mencoder-copy+copy.avi
When I try to play the files:

0300-ffmpeg-libxvid-mencoder-copy+copy.avi
0300-ffmpeg-mpeg4-mencoder-copy+copy.avi
0300-ffmpeg-msmpeg4-mencoder-copy+copy.avi

device opens each file, plays it for 17–18 seconds, then stops to play, and displays the message: “Can’t Playable.”.

It’s very strange and looks like some new bug caused by ffmpeg and mencoder working together.

***

At that point my invention ran down. Maybe you have an idea what method I could use in order to encode the original movie.avi file to the file acceptable by my recorder device?
 
Old 02-15-2013, 11:22 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Little known fact: many of these players have a size limit to files they can play. I found this out the hard way. From my Panasonic ones it's about 1GB. Split the files and it might work.

The options I use to make sure it plays on the player are:
Code:
ffmpeg -i input.mkv -vcodec libxvid -qscale 5 -s 640x272 -aspect 40:17 -r 23.976 -g 240 -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2 -pass 1 -an -f rawvideo -y /dev/null
ffmpeg -i input.mkv -vcodec libxvid -qscale 5 -s 640x272 -aspect 40:17 -r 23.976 -g 240 -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2 -pass 2 -f avi output.avi
I haven't tested all these options recently, because I haven't encoded anything recently, but they should work. Remove any that don't work.

I have tried using mencoder, but there's no guarantee the files it produces will be playable ... or maybe I just haven't found the right options.
 
1 members found this post helpful.
Old 02-15-2013, 11:29 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,730

Rep: Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919
I thought I had a better idea but nope...

Last edited by michaelk; 02-15-2013 at 11:37 AM.
 
Old 02-15-2013, 05:10 PM   #4
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Original Poster
Rep: Reputation: 234Reputation: 234Reputation: 234
H_TeXMeX_H,

I tried a few variants of your commands and I wrote a useful script that prepares AVI files in the format accepted by different devices (including my DVD/HD Recorder):

any2avi
Code:
#!/bin/bash

# any2avi: converts any video file to avi file

width=720
height=384
fps=29.970

infile="$1"
pass=$2

if [ "$pass" == "" ] ; then echo "$0 \"infile\" pass" ; exit ; fi

format=`echo $1 | sed 's/.*\.//'`
outfile="${infile%.$format}"

if [ "$pass" == "2" ]
then
    echo "# time = movie x 1.10"
    ffmpeg -i "$infile" -vcodec libxvid -qscale:v 3 -s ${width}x${height} -r $fps -g 240 -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2 -pass 1 -an -f rawvideo -y /dev/null
    ffmpeg -i "$infile" -vcodec libxvid -qscale:v 3 -s ${width}x${height} -r $fps -g 240 -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2 -pass 2     -f avi "$outfile-2".avi
elif [ "$pass" == "1" ]
then
    echo "# time = movie x 0.67"
    ffmpeg -i "$infile" -vcodec libxvid -qscale:v 3 -s ${width}x${height} -r $fps -g 240 -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2             -f avi "$outfile-1".avi
fi
It accepts two parameters: infile (any movie file) and pass (2 or 1).

Before running it it’s necessary to set the variables: width, height, and fps.

As for the resulting file size I didn’t have to split it into 1 GB parts because my recorder played well the 1.4 GB file.

Thank you very much for the tips.

---------- Post added 16th Feb 2013 at 00:11 ----------

michaelk,

could you share it with us (despite the problem is solved).
 
Old 02-16-2013, 02:45 AM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Make sure to take into account the maximum bitrate the player can handle. Some players can't handle higher bitrate, and that's why I had to use qscale 5. It varies from player to player, so you'll just have to test it or check the manual.
 
Old 02-16-2013, 05:13 AM   #6
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Original Poster
Rep: Reputation: 234Reputation: 234Reputation: 234
H_TeXMeX_H,

As I mentioned above I tried a few variants of your commands.

The ffmpeg used with your original commands displayed the warning:

Quote:
Please use -q:a or -q:v, -qscale is ambiguous
So first instead of the option:

-qscale 5

I used the options:

-qscale:v 3 -qscale:a 4

The resulting file behaved exactly as I described it in the 5th scenario: played for a while and then stopped to play.

Then I used the option for the video stream only:

-qscale:v 3

The resulting file played well.

So the option for the audio stream causes some problems.

I tried also the command from the 4th scenario removing the option concerning the audio stream but the resulting file behaved exactly as I described it in the 4th scenario: displayed a black screen.

So removing from my command the option concerning the audio stream isn’t enough because it’s necessary to add to it some options from your commands. I didn’t test that step by step but instead I wrote my script.

The script used with your -qscale:v 5 option works roughly as long as the script used with my -qscale:v 3 option but of course your option produces smaller file than mine.

Your remark about the devices with the limited bitrate may be helpful for the other users.
 
Old 02-16-2013, 07:37 AM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
I didn't know there was an audio qscale. Don't use an audio qscale.
 
Old 02-16-2013, 02:06 PM   #8
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Original Poster
Rep: Reputation: 234Reputation: 234Reputation: 234
As I described that above obsolete -qscale x is now replaced by -qscale:v x and -qscale:a y. The program still understands the old option and uses it for video stream only. After splitting that option between video and audio streams it turned out that my recorder doesn’t accept the setting for the audio stream.
 
Old 02-17-2013, 04:13 PM   #9
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Another thing to realize is that the file ending, such as ".avi", generally refers to the container format. There's still a question of what actual codecs were used for the video and audio streams inside the file, as well as what parameters were used. .avi and .mkv in particular can support a very large range of codecs and settings.

So check the output of ffmpeg carefully and see what the input values are for each stream and confirm that your player can handle what you're giving it.

In any case it looks like you're going to have to play around to figure out what range of ffmpeg settings you can use, to convert it into something that your player can understand.
 
Old 02-18-2013, 10:43 AM   #10
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Original Poster
Rep: Reputation: 234Reputation: 234Reputation: 234
David the H.,

When I use the script from the post #4 to convert the invalid video file into valid one ffmpeg reports:

Code:
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 -> libxvid)
  Stream #0:1 -> #0:1 (ac3 -> libmp3lame)
So the original file uses unaccepted by my device mpeg4 and ac3 codes while ffmpeg produces the file using accepted libxvid and libmp3lame codecs.

***

As I reported in posts #6 and #8 it isn’t enough to use the valid codecs because some other options can cause the resulting file will be accepted or rejected by the particular device. As H_TeXMeX_H reported in post #2 the valid codecs and options aren’t enough as well because some devices doesn’t accept too big files.

Last edited by w1k0; 02-18-2013 at 10:52 AM.
 
Old 03-13-2013, 12:07 AM   #11
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Original Poster
Rep: Reputation: 234Reputation: 234Reputation: 234
I can't edit post #4 so I publish the improved version of the script here:

any2avi
Code:
#!/bin/bash

# any2avi: converts any video file to avi file

infile="$1"
pass=$2

if [ "$pass" == "" ] ; then echo "$0 \"infile\" pass" ; exit ; fi

string=`mplayer "$infile" -endpos 1 2> /dev/null | grep fps`

scale=`echo $string | awk '{print $3}'`
fps=`echo $string | awk '{print $5}'`

#scale=720x576
#fps=25.000

aspect=$scale
aspect=${aspect/x//}
aspect=`echo "scale=2 ; $aspect" | bc`

gop=$fps
gop=${gop:0:4}
gop=${gop/./}

function run() {
    echo "#  scale = 720x576 (recommended)"
    echo "# aspect = 1.25    (recommended)"
    echo
    echo "#  scale = $scale (used)"
    echo "# aspect = $aspect    (used)"
    echo "#    fps = $fps  (used)"
    echo "#    gop = $gop     (used)"
    echo
    echo $command
    echo
    eval $command
}

format=`echo $1 | sed 's/.*\.//'`
outfile="${infile%.$format}"

if [ "$pass" == "2" ]
then
    reset
    echo "#   time = 1.10 x movie"
    echo
    command="ffmpeg -i \"$infile\" -vcodec libxvid -qscale:v 3 -s $scale -r $fps -g $gop -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2 -pass 1 -an -f rawvideo -y /dev/null"
    run
    command="ffmpeg -i \"$infile\" -vcodec libxvid -qscale:v 3 -s $scale -r $fps -g $gop -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2 -pass 2     -f avi \"$outfile-2\".avi"
    run
elif [ "$pass" == "1" ]
then
    reset
    echo "#   time = 0.67 x movie"
    echo
    command="ffmpeg -i \"$infile\" -vcodec libxvid -qscale:v 3 -s $scale -r $fps -g $gop -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2             -f avi \"$outfile-1\".avi"
    run
fi
My device doesn't accept the resolution higher than 720x576 so some other devices probably do the same.

For the best results align the scale and fps with the real values.

To determine them use the command such as:

mplayer movie.avi | grep fps

If you changed the fps value it'll be necessary to rescale the subtitles.

Last edited by w1k0; 03-13-2013 at 07:25 PM. Reason: update
 
Old 03-13-2013, 09:39 AM   #12
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
If you are going to use an fps variable, make '-g' GOP 10xFPS. So 250 in the case of 25 FPS. This is what they recommend in some tutorial, maybe the ffmpeg one.
 
1 members found this post helpful.
Old 03-13-2013, 10:18 AM   #13
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Original Poster
Rep: Reputation: 234Reputation: 234Reputation: 234
Thanks. I'll try it later.
 
Old 03-13-2013, 05:17 PM   #14
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Original Poster
Rep: Reputation: 234Reputation: 234Reputation: 234
I played with the option -g and I tried to play with -profile, -preset, and -tune options (see: 'x264 --fullhelp | less'). So far the best results give the commands used in the above script (I practically can't see the difference between one- and two-pass conversions). The major disadvantage of such a conversion is blocking that appears during the scenes in the dark when a lot of small objects moves fast.
 
Old 03-13-2013, 08:42 PM   #15
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Original Poster
Rep: Reputation: 234Reputation: 234Reputation: 234
The new version of the script scales the movie down to 720x576 automatically:

Code:
#!/bin/bash

# any2avi: converts any video file to avi file

infile="$1"
pass=$2

if [ "$pass" == "" ] ; then echo "$0 \"infile\" pass" ; exit ; fi

string=`mplayer "$infile" -endpos 1 2> /dev/null | grep fps`

scale=`echo $string | awk '{print $3}'`
fps=`echo $string | awk '{print $5}'`

#scale=720x576
#fps=25.000

width=$scale
width=${width/x*/}
height=$scale
height=${height/*x/}

orig_scale=$scale
orig_aspect=`echo "scale=2 ; ${width}/${height}" | bc`

function test_width() {
    if [ $width -gt 720 ]
    then
        factor=`echo "scale=2 ; $width/720" | bc`
        width=720
        height=`echo "$height/$factor" | bc`
        height=${height/.*/}
        scale=${width}x${height}
    fi
}

function test_height() {
    if [ $height -gt 576 ]
    then
        factor=`echo "scale=2 ; $height/576" | bc`
        height=576
        width=`echo "$width/$factor" | bc`
        width=${width/.*/}
        scale=${width}x${height}
    fi
}

test_width
test_height

aspect=`echo "scale=2 ; ${width}/${height}" | bc`

gop=$fps
gop=${gop:0:4}
gop=${gop/./}

function run() {
    echo "# recommended:"
    echo "#  scale = 720x576"
    echo "# aspect = 1.25"
    echo
    echo "# original:"
    echo "#  scale = $orig_scale"
    echo "# aspect = $orig_aspect"
    echo
    echo "# used:"
    echo "#  scale = $scale"
    echo "# aspect = $aspect"
    echo "#    fps = $fps"
    echo "#    gop = $gop"
    echo
    echo $command
    echo
    eval $command
}

format=`echo $1 | sed 's/.*\.//'`
outfile="${infile%.$format}"

if [ "$pass" == "2" ]
then
    reset
    echo "#   time = 1.10 x movie"
    echo
    command="ffmpeg -i \"$infile\" -vcodec libxvid -qscale:v 3 -s $scale -aspect $aspect -r $fps -g $gop -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2 -pass 1 -an -f rawvideo -y /dev/null"
    run
    command="ffmpeg -i \"$infile\" -vcodec libxvid -qscale:v 3 -s $scale -aspect $aspect -r $fps -g $gop -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2 -pass 2     -f avi \"$outfile-2\".avi"
    run
elif [ "$pass" == "1" ]
then
    reset
    echo "#   time = 0.67 x movie"
    echo
    command="ffmpeg -i \"$infile\" -vcodec libxvid -qscale:v 3 -s $scale -aspect $aspect -r $fps -g $gop -bf 2 -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2             -f avi \"$outfile-1\".avi"
    run
fi

Last edited by w1k0; 03-13-2013 at 08:53 PM. Reason: update
 
  


Reply



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 create a DVD that can play in a DVD player from regular .avi videos? whited Linux - Software 2 04-09-2008 05:45 PM
I can't play .avi file Gins Linux - General 9 08-19-2007 01:56 PM
convert .avi's to play on a dvd player kryptobs2000 Linux - Software 8 01-11-2007 11:23 PM
Cannot Play back DVD on PC recorded from a DVD recorder shazam75 Linux - Software 2 12-29-2005 03:11 AM
No colour when I play DVD or AVI videoos annashaw Linux - Laptop and Netbook 1 02-08-2005 04:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:47 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
Open Source Consulting | Domain Registration