2

There are many audio and video players but I would like to use one tool for many propose. So I would like to use ffplay as audio and video player.

To play a one file the command is like this.

ffplay path_to_audio_file.mp3

but how to play a list of audio files or a list of videos?

I tried to use:

ffplay *.mp3

but with no success, it gives me an error like this:

Argument 'audiofileB.mp3' provided as input filename, but 'audiofileA.mp3' was already specified.

3

ffplay appears to only support a single input file, so you'll need to use code to loop over a list of input files (and possibly to shuffle them); wildly assuming coreutils (for shuf), perhaps something like:

find musicdir -type f -name "*.mp3" | shuf | while read f; do ffplay -autoexit -- "$f"; done

This will of course break horribly if there are spaces or newlines in the filenames.

(My current music player is fairly similar, find ~/music -type f -name "*.mp3" | mpg123 --shuffle -Z --list -)

  • I tried you solution and it's almost good, but ... there are some problems related to ffplay which I'm not sure if they should be resolved in this question or in another. one of problems is that ffplay will not end playing current song and for this reason will not go to the next song at the end of current untill I will not use CTRL+c keyboard combination. – Scantlight Apr 11 '16 at 21:29
  • 1
    @Scantlight the -autoexit flag seems relevant to that issue. – thrig Apr 11 '16 at 23:33
  • -autoexit solved that issue. Now I have another which can be solved by using -nodisp ... this will disable the visualisation of waveform and similar stuff. This will avoid to create a new window and steal focus from current working application (this was very annoying behavior). would you like to include this option in your answer, as a possible option to solve the annoying behavior. – Scantlight Apr 12 '16 at 11:43
1

I found this thread while I was writing an FFplay GUI in Lazarus/FPC. It could already play a dropped file list and skip to next/previous file, but I had to kill the ffmpeg process and create a new one every time. I was trying to add the ability to play a whole file list. The simplest workaround I found to the moment was of course using -autoexit, and creating a playlist file with this Pascal code:

begin
      AssignFile(tfOut, C_FNAME);
      try
        rewrite(tfOut);
        for i:= 0 to Fichiers.Items.Count - 1 do
        if Fichiers.Selected[i] then
        begin
          writeln(tfOut, 'file ' + #39 + conv(Fichiers.Items[i]) + #39)
        end;
        CloseFile(tfOut);
      except
        on E: EInOutError do
        ShowMessage ('File error')
      end;
  end;

Then reading it this way:

'ffplay -f concat -safe 0 -i flist.txt -autoexit'

which is the same syntax I use for concatenating files with FFMPeg.

I'm now searching for a proper way to add a delay if files are image files…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.