Find the answer to your Linux question:
Results 1 to 3 of 3
Hi I am trying to dothe following. I have a movie server and I want to convert my avi movies to mkv files automaticly. in below code I try to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2011
    Posts
    1

    String manipulation help needed


    Hi I am trying to dothe following.

    I have a movie server and I want to convert my avi movies to mkv files automaticly.
    in below code I try to find the name of the avi file present in the folder, and strip the extension of it so I can use the same name as the original for the mkv file.

    my output is:
    Code:
    we will be using  dexterS6E2.avi as input videofile
    ./run.sh: line 4: dexterS6E2: No such file or directory

    Code:
    #/bin/bash
    INPUTFILE=`find -type f -name \*.avi`
    echo 'we will be using ' $INPUTFILE 'as input videofile'
    OUTPUTSTACK=`${INPUTFILE%.avi}`
    OUTPUTFILE=`echo $OUTPUTSTACK '.mkv'`
    echo 'The output videofile will be ' $OUTPUTFILE 
    ffmpeg -i $INPUTFILE -vcodec ffv1 -acodec pcm_s16le $OUTPUTFILE
    I have also tried to use the expr lengt and results in the same output
    Code:
    export NAMELENGTH=`expr length $INPUTFILE`
    export OUTPUTLENGTH=`expr $NAMELENGTH - 5`
    export OUTPUTFILE=`${INPUTFILE:2:OUTPUTLENGTH}`
    I have a verry basic knowledge of scripting and tried to check for alternative ways but can't see why it outputs that way.

    anyone able to help?

    thanks

  2. #2
    Just Joined!
    Join Date
    Mar 2007
    Location
    Bogotá, Colombia
    Posts
    44
    Hello!

    Well, I would use sed to change the extensio of your file.

    check this out:

    Code:
    A=myfile.avi ; B=`echo $A | sed -r 's/\.avi$/\.mkv/'` ; echo $A $B
    if you already have the original name, it is very simple to change the extension of it with sed.

    I hope it helps.

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,397
    To convert an avi file (avi is just a wrapper for other protocols, such as mp4) to an mkv file, you need to transcode it with a tool such as ffmpeg, which will do this in a streaming manner as you want. Here is a link to the ffmpeg web site: FFmpeg
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •