Re: using pipes in ffmpeg

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

Re: using pipes in ffmpeg

ben27



Michel Bardiaux <mbardiaux <at> mediaxim.be> writes:

>
> Pierpaolo Gull?a a écrit :
> > @Micheal
> >
> > Thanks for your help , how I can use pipes with ffmpeg?
>
> Easy: for named pipes, use the name; for anonymous pipes (stdin/stdout),
> use the name "-".
>
> > what lilitattions i can have?
>
> Some containers wont work correctly using pipes. Notably those
> containers that need to seek back to the start of the output file to
> finalize the header. That rules out AVI and WAV over pipes.
>
> >
> > Thanks a lot
> >
> > Br
>

I am sorry that I did not explain my problem more detailed.

I try to build a service-oriented environment for video processing and though
about using command-line tools as a basic unit for doing the video adaptation.

Because I can not accept a caching on the harddisk I tried to use pipes.

I used three terminals:

one for writing content in a pipe:
cat X.avi > /home/xx/input.pipe

one for reading out of another pipe and writing in a file:
cat output.pipe > Test.avi

one for ffmpeg:
ffmpeg -r 25 -i input.pipe -r 25 -f avi -y output.pipe


But, it does not work. I tried different options for ffmpeg, but maybe I did not
find the right combination. Or is the problem that an avi-file can not be
processed from a pipe? You mentioned something like that above. Can you explain
it more detailed? I know that mencoder supports a processing like that.

Can you help me?
Thanks a lot.



_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: using pipes in ffmpeg

Michel Bardiaux-2
ben27 a écrit :

>
>
> Michel Bardiaux <mbardiaux <at> mediaxim.be> writes:
>
>> Pierpaolo Gull?a a écrit :
>>> @Micheal
>>>
>>> Thanks for your help , how I can use pipes with ffmpeg?
>> Easy: for named pipes, use the name; for anonymous pipes (stdin/stdout),
>> use the name "-".
>>
>>> what lilitattions i can have?
>> Some containers wont work correctly using pipes. Notably those
>> containers that need to seek back to the start of the output file to
>> finalize the header. That rules out AVI and WAV over pipes.
>>
>>> Thanks a lot
>>>
>>> Br
>
> I am sorry that I did not explain my problem more detailed.
>
> I try to build a service-oriented environment for video processing and though
> about using command-line tools as a basic unit for doing the video adaptation.
>
> Because I can not accept a caching on the harddisk I tried to use pipes.
>
> I used three terminals:
>
> one for writing content in a pipe:
> cat X.avi > /home/xx/input.pipe
>
> one for reading out of another pipe and writing in a file:
> cat output.pipe > Test.avi
>
> one for ffmpeg:
> ffmpeg -r 25 -i input.pipe -r 25 -f avi -y output.pipe
>
>
> But, it does not work. I tried different options for ffmpeg, but maybe I did not
> find the right combination. Or is the problem that an avi-file can not be
> processed from a pipe?

Yes.

> You mentioned something like that above. Can you explain
> it more detailed?

Somewhere near the start of an AVI, its final size must be written, and
that requires seeking to the start of the file, which cant be done on a
pipe.

> I know that mencoder supports a processing like that.

Interesting. I have it installed so if you post an example command I can
try it. Though at this point I cant imagine how they do it.

>

--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: using pipes in ffmpeg

ben27
Michel Bardiaux <mbardiaux <at> mediaxim.be> writes:

> > You mentioned something like that above. Can you explain
> > it more detailed?
>
> Somewhere near the start of an AVI, its final size must be written, and
> that requires seeking to the start of the file, which cant be done on a
> pipe.
>
> > I know that mencoder supports a processing like that.
>
> Interesting. I have it installed so if you post an example command I can
> try it. Though at this point I cant imagine how they do it.
>
> >
>

Here is an example that worked fine for me. It does a scaling and
uses an Input and Output pipe. But it works only with avi-files!
I am not sure, but maybe the ...-library has problems with mpeg-files?

mencoder inputPipe -ovc lavc -lavcopts vcodec=mpeg4 -of avi -vop
scale=1024:600 -sws 2 -oac copy -o outputPipe -quiet

By the way, my ffmpeg-command was ok? Or must I add anything or remove?


_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: using pipes in ffmpeg

Michel Bardiaux-2
ben27 a écrit :

> Michel Bardiaux <mbardiaux <at> mediaxim.be> writes:
>
>>> You mentioned something like that above. Can you explain
>>> it more detailed?
>> Somewhere near the start of an AVI, its final size must be written, and
>> that requires seeking to the start of the file, which cant be done on a
>> pipe.
>>
>>> I know that mencoder supports a processing like that.
>> Interesting. I have it installed so if you post an example command I can
>> try it. Though at this point I cant imagine how they do it.
>>
>
> Here is an example that worked fine for me. It does a scaling and
> uses an Input and Output pipe. But it works only with avi-files!
> I am not sure, but maybe the ...-library has problems with mpeg-files?
>
> mencoder inputPipe -ovc lavc -lavcopts vcodec=mpeg4 -of avi -vop
> scale=1024:600 -sws 2 -oac copy -o outputPipe -quiet
>
> By the way, my ffmpeg-command was ok? Or must I add anything or remove?

ffmpeg -r 25 -i input.pipe -r 25 -f avi -y output.pipe

-r 25 not needed on input

-r 25 (or rather, the same fps) will be the default on output.

-vcodec needed on output. And -b. The default is 200kbits, you probably
want better quality.

BTW you should neever post vague indications like "doesnt work". Always
post the command line (you did) with the full output messages (you
didnt) and specifics of what fails. IOW, help others to help you!

Greetings,
--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: using pipes in ffmpeg

ben27
Michel Bardiaux <mbardiaux <at> mediaxim.be> writes:
 

> ffmpeg -r 25 -i input.pipe -r 25 -f avi -y output.pipe
>
> -r 25 not needed on input
>
> -r 25 (or rather, the same fps) will be the default on output.
>
> -vcodec needed on output. And -b. The default is 200kbits, you probably
> want better quality.
>
> BTW you should neever post vague indications like "doesnt work". Always
> post the command line (you did) with the full output messages (you
> didnt) and specifics of what fails. IOW, help others to help you!


Ok, thanks. I will fix my command. Furthermore, I will report the output message
next time.

It works now with a mpeg-file from the terminal. But I get no processing when I
try to start ffmpeg from a Java program. No error message, only an empty
file???? Any idea??? I can start mencoder from my program, but not ffmpeg.

Please let me know if you find out something new about mencoder processing
avi-files ;)

Greetings,
Benjamin



_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: using pipes in ffmpeg

Michel Bardiaux-2
ben27 a écrit :

> Michel Bardiaux <mbardiaux <at> mediaxim.be> writes:
>  
>> ffmpeg -r 25 -i input.pipe -r 25 -f avi -y output.pipe
>>
>> -r 25 not needed on input
>>
>> -r 25 (or rather, the same fps) will be the default on output.
>>
>> -vcodec needed on output. And -b. The default is 200kbits, you probably
>> want better quality.
>>
>> BTW you should neever post vague indications like "doesnt work". Always
>> post the command line (you did) with the full output messages (you
>> didnt) and specifics of what fails. IOW, help others to help you!
>
>
> Ok, thanks. I will fix my command. Furthermore, I will report the output message
> next time.
>
> It works now with a mpeg-file from the terminal. But I get no processing when I
> try to start ffmpeg from a Java program. No error message, only an empty
> file???? Any idea???

No, I dont use Java (though I drink a lot of java...)

> I can start mencoder from my program, but not ffmpeg.
>
> Please let me know if you find out something new about mencoder processing
> avi-files ;)

Can you confirm the avi produced by mencoder through a named pipe, plays
OK in WMP?


--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: using pipes in ffmpeg

ben27
Michel Bardiaux <mbardiaux <at> mediaxim.be> writes:

> Can you confirm the avi produced by mencoder through a named pipe, plays
> OK in WMP?

WMP = Windows Media Player?

I only tested it under Linux. I use Xine and Mplayer to play it.
VLC has some problems. I am not sure why VLC can not play it.




_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: using pipes in ffmpeg

Michel Bardiaux-2
ben27 a écrit :
> Michel Bardiaux <mbardiaux <at> mediaxim.be> writes:
>
>> Can you confirm the avi produced by mencoder through a named pipe,
>> plays OK in WMP?
>
> WMP = Windows Media Player?

Yep. Picky, not to say flaky, thus a stronger validator.

>
> I only tested it under Linux. I use Xine and Mplayer to play it. VLC
> has some problems. I am not sure why VLC can not play it.
>
Probably because it is not a fully conforming avi. Playing with mplayer
proves nothing, mplayer is deliberately permissive. Eg it allows MPEG1
in avi!

I have made a quick try, you *can* create an avi though a pipe with ffmpeg:

ffmpeg -i ~/internet/ffmpeg-svn-bmp/tmp/utc_1434.mpg -vcodec msmpeg4v2
-f avi - > x-pipe.avi
FFmpeg version SVN-r11006, Copyright (c) 2000-2007 Fabrice Bellard, et al.
   configuration: --enable-gpl --enable-liba52 --enable-libgsm
--enable-libmp3lame
   libavutil version: 49.5.0
   libavcodec version: 51.48.0
   libavformat version: 51.19.0
   built on Nov 19 2007 15:06:05, gcc: 4.1.2 20061115 (prerelease)
(Debian 4.1.1-21)
Input #0, mpeg, from
'/besdev01/home/people/michel/internet/ffmpeg-svn-bmp/tmp/utc_1434.mpg':
   Duration: 00:00:59.9, start: 92564.370489, bitrate: 635 kb/s
     Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x288 [PAR 1:1
DAR 11:9], 104857 kb/s, 25.00 fps(r)
     Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, mono, 32 kb/s
Output #0, avi, to 'pipe:':
     Stream #0.0: Video: msmpeg4v2, yuv420p, 352x288 [PAR 1:1 DAR 11:9],
q=2-31, 200 kb/s, 25.00 fps(c)
     Stream #0.1: Audio: mp2, 48000 Hz, mono, 64 kb/s
Stream mapping:
   Stream #0.0 -> #0.0
   Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 1501 fps=410 q=24.8 Lsize=    2321kB time=60.0 bitrate=
316.9kbits/s
video:1818kB audio:469kB global headers:0kB muxing overhead 1.493583%

However, it does NOT play in WMP. The same but directly to file does,
though. cmp shows they differ at the very start of the file. Indded they
dont even have the same size!

Maybe this should be considered a bug rather than a feature?

--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: using pipes in ffmpeg

ben27
>Michel Bardiaux <mbardiaux <at> mediaxim.be> writes:
>
> However, it does NOT play in WMP. The same but directly to file does,
> though. cmp shows they differ at the very start of the file. Indded they
> dont even have the same size!
>
> Maybe this should be considered a bug rather than a feature?
>

Maybe ;)

Thank you again for your help. I learned not to use avi-files for streaming ;)
I did not get ffmpeg to work out of my Java program.

Now I use mencoder. That works fine. I have to check how to do scaling without
transcoding with mencoder. I did not found a solution until now :(


_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: using pipes in ffmpeg

Michel Bardiaux-2
ben27 a écrit :

>> Michel Bardiaux <mbardiaux <at> mediaxim.be> writes:
>>
>> However, it does NOT play in WMP. The same but directly to file does,
>> though. cmp shows they differ at the very start of the file. Indded they
>> dont even have the same size!
>>
>> Maybe this should be considered a bug rather than a feature?
>>
>
> Maybe ;)
>
> Thank you again for your help. I learned not to use avi-files for streaming ;)
> I did not get ffmpeg to work out of my Java program.

Not an ffmpeg issue.

>
> Now I use mencoder. That works fine. I have to check how to do scaling without
> transcoding with mencoder. I did not found a solution until now :(

Generally speaking, you cant rescale without re-encoding. The nearest
you can achieve, eg with MPEG1, is to use -vcodec copy and hack the
source to tweak bits in the stream to change the pixel-aspect-ratio.

--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user