ffmpeg gives error "Invalid data found when processing input" when concatenating jpg files

I have a server running Ubuntu 18.04 LTS.
I have a directory with a number of jpg files taken with an IP camera. I am trying to concatenate the jpg files into a single mpg video file using ffmpeg with the following command:

ffmpeg -f concat -i /tmp/myjpegs  /tmp/myvideo.mpg

I get the error message:
/tmp/myjpegs: Invalid data found when processing input

There is nothing else in the /tmp/myjpegs folder apart from the sequence of jpg files.

This the the output from the command:

  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
/tmp/myjpegs: Invalid data found when processing input
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
https://trac.ffmpeg.org/wiki/Concatenate provides instructions.

Problem is with your input directive.

The -i option requires passing a text file containing the list of files to concatenate, rather than a directory.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Tip: You can also try this.

cat /tmp/myjpegs* >  /tmp/myvideo.mpg

Open in new window

As I recall, .mpg containers can be directly concatenated.

I'd try this first + see if it works. I did some looking + couldn't find a definitive answer online + I don't have any .mpg footage available to test.

My suggestion is you try the Linux cat command first + see if that works.
ClintonKAuthor Commented:
Thanks, that was the key to the solution. Now that I have created a text file containing the names of the jpegs all works fine. (I had to add -safe 0 to the command line).

BTW. cat jpegs to mpg didn't seem to work.

Cheers for the help.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Glad you got this working!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Images and Photos

From novice to tech pro — start learning today.