Piping example?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Piping example?

Totte Karlsson
Hello,

I'm having an application that generates device dependent bitmaps that are
combined using ffmpeg into an avi file by giving ffmpeg a folder of them
written to file.

 

I would like to use a pipe and stream the frames directly to ffmpeg for avi
creation (possibly using compression) but can't find many examples of how to
do the piping part.

 

The code is running on Windows and everything is written in C++.

 

The only brief example I can find is in an answer on stackoverflow:
https://stackoverflow.com/questions/51903888/is-it-possible-to-send-ffmpeg-i
mages-by-using-pipe .

 

Anyone having a more worked out example by any chance?

 

Thanks,

-tk

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Piping example?

Carl Eugen Hoyos-2
Am Di., 1. Okt. 2019 um 18:41 Uhr schrieb Totte Karlsson <[hidden email]>:

> I'm having an application that generates device dependent bitmaps that are
> combined using ffmpeg into an avi file by giving ffmpeg a folder of them
> written to file.
>
> I would like to use a pipe and stream the frames directly to ffmpeg for avi
> creation (possibly using compression) but can't find many examples of how to
> do the piping part.
>
> The code is running on Windows and everything is written in C++.

Consider posting on libav-user:
https://ffmpeg.org/contact.html#MailingLists

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Piping example?

Totte Karlsson
Hi Carl,

Thanks for directing me to the libav-user mail list.

I would, however want to start and use the ffmpeg executable from within my program (in a process) and open the pipe programmatically, like in the brief stackoverflow example mentioned in my first post. This to avoid getting to deep into the ffmpeg code, as I believe that may be a larger project.

Thanks,
-tk





-----Original Message-----
From: ffmpeg-user [mailto:[hidden email]] On Behalf Of Carl Eugen Hoyos
Sent: Tuesday, October 01, 2019 9:47 AM
To: FFmpeg user questions <[hidden email]>
Subject: Re: [FFmpeg-user] Piping example?

Am Di., 1. Okt. 2019 um 18:41 Uhr schrieb Totte Karlsson <[hidden email]>:

> I'm having an application that generates device dependent bitmaps that
> are combined using ffmpeg into an avi file by giving ffmpeg a folder
> of them written to file.
>
> I would like to use a pipe and stream the frames directly to ffmpeg
> for avi creation (possibly using compression) but can't find many
> examples of how to do the piping part.
>
> The code is running on Windows and everything is written in C++.

Consider posting on libav-user:
https://ffmpeg.org/contact.html#MailingLists

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email [hidden email] with subject "unsubscribe".

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Piping example?

Carl Eugen Hoyos-2
Am Di., 1. Okt. 2019 um 19:18 Uhr schrieb Totte Karlsson <[hidden email]>:

> Thanks for directing me to the libav-user mail list.
>
> I would, however want to start and use the ffmpeg executable from
> within my program

Did you try the following?

$ ffmpeg -f lavfi -i testsrc -f rawvideo -

and:

$ ffmpeg -f rawvideo -s 320x240 -pix_fmt rgb24 -i - out.avi

Please find out what top-posting means and avoid it here, Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Piping example?

Totte Karlsson
 
> Did you try the following?
>
> $ ffmpeg -f lavfi -i testsrc -f rawvideo -
>
> and:
>
> $ ffmpeg -f rawvideo -s 320x240 -pix_fmt rgb24 -i - out.avi
>
 
I did not test that but will test later today. My bitmaps are 658 x 492 and are greyscale 8 bits and are acquired at 100fps.

I assume the  line
> $ ffmpeg -f lavfi -i testsrc -f rawvideo -

means streaming to standard out?

I'll get back with my findings..!
Thanks!
 


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Piping example?

Carl Eugen Hoyos-2
Am Di., 1. Okt. 2019 um 19:53 Uhr schrieb Totte Karlsson <[hidden email]>:

>
>
> > Did you try the following?
> >
> > $ ffmpeg -f lavfi -i testsrc -f rawvideo -
> >
> > and:
> >
> > $ ffmpeg -f rawvideo -s 320x240 -pix_fmt rgb24 -i - out.avi
> >
>
> I did not test that but will test later today. My bitmaps are
> 658 x 492 and are greyscale 8 bits and are acquired at 100fps.

You asked for an example.

> I assume the  line
> > $ ffmpeg -f lavfi -i testsrc -f rawvideo -
>
> means streaming to standard out?

Yes.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Piping example?

Totte Karlsson
Hello,
I got streaming working using a named pipe on Windows. Great!

The camera (Allied Vision) is streaming 80fps to the pipe.

I'm reading from the pipe like this:
ffmpeg  -y -vcodec rawvideo -f rawvideo -hide_banner  -s 658x492 -pix_fmt gray -i \\\\.\\pipe\\Pipe -vsync vfr out.avi

The output video seem to have all the frames and the output looks good. However, the video plays about 3.5 times slower than the input!?

The output from ffmpeg when running looks like this:

Input #0, rawvideo, from '\\.\pipe\Pipe':
  Duration: N/A, start: 0.000000, bitrate: 64747 kb/s
    Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 658x492, 64747 kb/s, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
[swscaler @ 0000014f03772000] Warning: data is not aligned! This can lead to a speed loss
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf58.33.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 658x492, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.59.101 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A

frame=  327 fps= 81 q=5.8 size=     518kB time=00:00:13.08 bitrate= 324.1kbits/s speed=3.22x

and the last 'frame':
frame=  401 fps= 66 q=8.3 Lsize=     704kB time=00:00:16.04 bitrate= 359.6kbits/s speed=2.65x


I also tried -r 80, instead of the -vsync vfr, but the result is the same..

Any helpers appreciated!

-tk





> -----Original Message-----
> From: ffmpeg-user [mailto:[hidden email]] On Behalf Of Carl
> Eugen Hoyos
> Sent: Tuesday, October 01, 2019 10:55 AM
> To: FFmpeg user questions <[hidden email]>
> Subject: Re: [FFmpeg-user] Piping example?
>
> Am Di., 1. Okt. 2019 um 19:53 Uhr schrieb Totte Karlsson <[hidden email]>:
> >
> >
> > > Did you try the following?
> > >
> > > $ ffmpeg -f lavfi -i testsrc -f rawvideo -
> > >
> > > and:
> > >
> > > $ ffmpeg -f rawvideo -s 320x240 -pix_fmt rgb24 -i - out.avi
> > >
> >
> > I did not test that but will test later today. My bitmaps are
> > 658 x 492 and are greyscale 8 bits and are acquired at 100fps.
>
> You asked for an example.
>
> > I assume the  line
> > > $ ffmpeg -f lavfi -i testsrc -f rawvideo -
> >
> > means streaming to standard out?
>
> Yes.
>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email [hidden email] with
> subject "unsubscribe".

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Piping example?

Totte Karlsson
To follow up to this thread;

I got recording using a named pipe on windows working reliably with the following command:

ffmpeg.exe-y -hide_banner -vcodec rawvideo -f rawvideo -r 80 -s 658x492 -pix_fmt gray -i \\.\pipe\DEV_000F315BE933 -r 80 -c:v rawvideo X:\DEV_000F315BE933_2019T100914.avi

I could not get proper replay speed without using the both -r 80.

-tk


> -----Original Message-----
> From: Totte Karlsson [mailto:[hidden email]]
> Sent: Wednesday, October 09, 2019 5:17 PM
> To: 'FFmpeg user questions' <[hidden email]>
> Subject: RE: [FFmpeg-user] Piping example?
>
> Hello,
> I got streaming working using a named pipe on Windows. Great!
>
> The camera (Allied Vision) is streaming 80fps to the pipe.
>
> I'm reading from the pipe like this:
> ffmpeg  -y -vcodec rawvideo -f rawvideo -hide_banner  -s 658x492 -pix_fmt gray -i
> \\\\.\\pipe\\Pipe -vsync vfr out.avi
>
> The output video seem to have all the frames and the output looks good. However,
> the video plays about 3.5 times slower than the input!?
>
> The output from ffmpeg when running looks like this:
>
> Input #0, rawvideo, from '\\.\pipe\Pipe':
>   Duration: N/A, start: 0.000000, bitrate: 64747 kb/s
>     Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 658x492, 64747 kb/s,
> 25 tbr, 25 tbn, 25 tbc Stream mapping:
>   Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native)) Press [q] to stop, [?] for
> help [swscaler @ 0000014f03772000] Warning: data is not aligned! This can lead to
> a speed loss Output #0, avi, to 'out.avi':
>   Metadata:
>     ISFT            : Lavf58.33.100
>     Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 658x492, q=2-31,
> 200 kb/s, 25 fps, 25 tbn, 25 tbc
>     Metadata:
>       encoder         : Lavc58.59.101 mpeg4
>     Side data:
>       cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
>
> frame=  327 fps= 81 q=5.8 size=     518kB time=00:00:13.08 bitrate= 324.1kbits/s
> speed=3.22x
>
> and the last 'frame':
> frame=  401 fps= 66 q=8.3 Lsize=     704kB time=00:00:16.04 bitrate= 359.6kbits/s
> speed=2.65x
>
>
> I also tried -r 80, instead of the -vsync vfr, but the result is the same..
>
> Any helpers appreciated!
>
> -tk
>
>
>
>
>
> > -----Original Message-----
> > From: ffmpeg-user [mailto:[hidden email]] On Behalf Of
> > Carl Eugen Hoyos
> > Sent: Tuesday, October 01, 2019 10:55 AM
> > To: FFmpeg user questions <[hidden email]>
> > Subject: Re: [FFmpeg-user] Piping example?
> >
> > Am Di., 1. Okt. 2019 um 19:53 Uhr schrieb Totte Karlsson <[hidden email]>:
> > >
> > >
> > > > Did you try the following?
> > > >
> > > > $ ffmpeg -f lavfi -i testsrc -f rawvideo -
> > > >
> > > > and:
> > > >
> > > > $ ffmpeg -f rawvideo -s 320x240 -pix_fmt rgb24 -i - out.avi
> > > >
> > >
> > > I did not test that but will test later today. My bitmaps are
> > > 658 x 492 and are greyscale 8 bits and are acquired at 100fps.
> >
> > You asked for an example.
> >
> > > I assume the  line
> > > > $ ffmpeg -f lavfi -i testsrc -f rawvideo -
> > >
> > > means streaming to standard out?
> >
> > Yes.
> >
> > Carl Eugen
> > _______________________________________________
> > ffmpeg-user mailing list
> > [hidden email]
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-user
> >
> > To unsubscribe, visit link above, or email
> > [hidden email] with subject "unsubscribe".


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Piping example?

Carl Eugen Hoyos-2
Am Mo., 14. Okt. 2019 um 19:12 Uhr schrieb Totte Karlsson <[hidden email]>:

> I got recording using a named pipe on windows working reliably with the following command:
>
> ffmpeg.exe-y -hide_banner -vcodec rawvideo -f rawvideo -r 80 -s 658x492 -pix_fmt gray -i \\.\pipe\DEV_000F315BE933 -r 80 -c:v rawvideo X:\DEV_000F315BE933_2019T100914.avi
>
> I could not get proper replay speed without using the both -r 80.

The output option has no effect.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".