[MPlayer-users] Fwd: Trying to split avi file using mencoder

Alexander Roalter alex at roalter.it
Mon Sep 18 18:13:47 CEST 2006


wim delvaux wrote:
> Hi all,
> 
> Look at this little shell script :
> 
> if [ "$1" == "" ]
> then
>   echo "usage $0 filename"
>   exit 2
> fi
> 
> # calc half
> FS=`ls -s --block-size=1 "$1"`
> 
> BS=${FS% *}
> let BS=BS/2
> 
> Ext="${1##*.}"
> BN="${1%.*}"
> 
> # avisplit -i "$1" -o "$BN" -s ${FS%.*}
> # set to proper encoding
> mencoder -ffourcc XVID -ovc copy -oac lavc -lavcopts
> acodec=ac3:abitrate=224 -endpos ${BS}b "$1" -o "${BN}-1.${Ext}"
> mencoder -ffourcc XVID -ovc copy -oac lavc -lavcopts
> acodec=ac3:abitrate=224 -sb ${BS} "$1" -o "${BN}-2.${Ext}"
> 
> 
> The first mencoder works just fine.
> 
> The second one produces following error which I do not understand
> 
> MEncoder 2:0.99+1.0pre7try2+cvs20060117-0ubuntu8 (C) 2000-2006 MPlayer Team
> CPU: Intel Pentium 4/Celeron 4 Northwood; Pentium 4 EE/Xeon
>  Prestonia,Gallatin (Family: 15, Stepping: 7)
> CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
> Compiled with runtime CPU detection.
> success: format: 0  data: 0x0 - 0x57643bba
> ============ Sorry, this file format is not recognized/supported
>  ============= === If this file is an AVI, ASF or MPEG stream, please contact
>  the author! === Cannot open demuxer.
> 
> Exiting...
> 
> 
> what am I doing wrong ?
I'm not quite sure if this helps, but seeking to a specified byte 
position is always tricky, since mplayer should find a valid frame at 
the exact position. It's like jumping in the middle of a computer 
program, there's a great chance of finding only garbage, which only 
makes sense if the data preceeding it is also executed... from what I 
see you compute $BS simply by splitting the file in half, which is not 
that good an idea.

with the first line and -endpos, mplayer can handle that way better, you 
simply tell mplayer to stop when the Nth byte has been read. The 
preceeding bytes sill were read and could be played correctly, and no 
one buggers if the last byte you read didn't make a complete frame. Bear 
in mind though, that since you cut at a fairly arbitrary position, some 
bytes at the end of the file are lost (since you told mplayer to do so 
after byte N), and even if mplayer can handle the file (by sheer luck, I 
must stress), there's a great chance some bytes before mplayer regains 
its proper state are also lost.

the first line is probably better of with -frames, if there's a 
-start-frame command (or something like it) I'm not aware of, I'm quite 
happy with avisplit/merge at the moment (and cat in case of mpegs)...




More information about the MPlayer-users mailing list