Recherche avancée

Médias (0)

Mot : - Tags -/médias

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (104)

Sur d’autres sites (23977)

  • Tailing a logfile and processing each line is missing data when converting a file with ffmpeg

    8 avril 2014, par Chris.D

    I am running a script to tail a log file as per the code snippet below. I am running into a problem where by the line passed into $line is missing a number amount of bytes from the beginning when several lines are written to the log file at nearly the same time.

    I can check the file afterwards and see that the offending line is complete in the file so why is it incomplete in the script. Some kind of buffering issue perhaps ?

    The processing can sometimes take several seconds to complete would that make a difference ?

    #!/bin/bash
    tail -F /var/log/mylog.log | while read line
    do
      log "$line"
      ffmpeg -i "from.wav" "to.mp3"
    done

    Full line in file

    "12","","765467657","56753763","test"

    example logged $line

    657","56753763","test"

    Update
    I have done some more debugging of my code and it seems the processing that is causing the problem is a call to ffmpeg used to convert a wav to mp3. If I swap that with just a sleep then the problem goes away. Could ffmpeg effect the buffer somehow ?

  • Run a function from while read line

    2 octobre 2013, par user2783132

    I'm trying to run a function from while read line, the function contains ffmpeg commands to marge two files. but for some reason it's running the first $line and than breaks from loop.

    "$filesList" contains three lines. I'm not sure what's wrong, but i can confirm with echo "$OFILE" that opener function runs three times if I comment out the ffmpeg commands, and only once with ffmpeg commands.

    opener(){
           OFILE="$1"
           echo "$OFILE"

           ffmpeg -i $opener_path -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
           ffmpeg -i $OFILE -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
           ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc merge_$OFILE

           mv merge_$OFILE $OFILE
           rm intermediate1.ts intermediate2.ts
    }


    while read line; do
           if [ -e "$line" ]; then
                   opener "$line"
           fi
    done <<< "$filesList"
  • Running PHP from command line

    9 juin 2014, par Kit Carrau

    I am trying to manage a queue of files waiting to be processed by ffmpeg. A page is run using CRON that runs through a database of files waiting to be processed. The page then builds the commands and sends them to the command line using exec().

    However, when the PHP page is run from the command line or CRON, it runs the exec() OK, but does not return to the PHP page to continue updating the database and other functions.

    Example :

    <?php
    $cmd = "ffmpeg inpupt.mpg output.m4v";

    exec($cmd . ' 2>&1', $output, $return);

    //Page continues...but not executed
    $update = mysql_query("UPDATE.....");
    ?>

    When this page is run from the command line, the command is run using exec() but then the rest of the page is not executed. I think the problem may be that I am running a command using exec() in a page run from the command line.

    Is it possible to run a PHP page in full from the command line which includes exec() ?

    Or is there a better way of doing this ?

    Thank you.