Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-20-2009, 04:39 PM
|
#1
|
Member
Registered: Jan 2009
Location: Stockholm Sweden
Distribution: Ubuntu 9.10
Posts: 57
Rep:
|
How to store file in ffmpeg
I am running this command but I am unable to store a file contents. I dont know where is the problem, I am stuck on this from last 3 days. so now I decided to post on forum.
PHP Code:
ffmpeg -re -i movie.mpg -vcodec mpeg4 -an -f rtp rtp://x.x.x.x:123456 -vn -acodec mp2 -f rtp rtp://x.x.x.x:44444 -newaudio 2>/dev/null 1>/tmp/tmp_sdp&
head -n14 /tmp/tmp_sdp | tail -n13 > /home/jhon/movie.sdp
ffmpeg redirect the output successfully to the /tmp/tmp_sdp file, but when I tried to read the contents in script it is blank. But when I issued this command in Bash shell It prints all required values.
If you have any idea then please post some solution.
Thanks in Advanced
|
|
|
01-20-2009, 04:45 PM
|
#2
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
I think ffmpeg write messages to standard error instead of standard output. This is because of the ability to stream output to stdout if you use - as the output filename. Have you tried to substitute 2>/dev/null 1>/tmp/tmp_sdp with simply 2>/tmp/tmp_sdp?
|
|
|
01-20-2009, 04:57 PM
|
#3
|
Member
Registered: Jan 2009
Location: Stockholm Sweden
Distribution: Ubuntu 9.10
Posts: 57
Original Poster
Rep:
|
yes I have tired, but no success. Becuase ffmpeg use 2 as a stderr and 1 as stdout and therefor I redirect all error to /dev/null and I only want the output of this command. thatshwy I redirect it to temp file which I want to use it for process but I am not able to 'cat' this file contents to any other file it. Even when I tried to cat tmp file it shows me all the contents but when I tried to use this same command which I run in the Bash Shell succesfuly shows me blank result. I dont know what is the problem. Hope you gave me better suggestion. 
|
|
|
01-20-2009, 05:17 PM
|
#4
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
Sorry but I don't understand. Look at the following example:
Code:
$ ffmpeg -i "movie.mpg" -vcodec mpeg4 movie.avi > ./ffmpeg.log
<output displayed here>
<output displayed here>
<omitted>
$ ls -l
-rw-r--r-- 1 colucix users 0 2009-01-21 00:06 ffmpeg.log
-rw-r--r-- 1 colucix users 58653112 2008-12-28 21:53 movie.mpg
-rw-r--r-- 1 colucix users 13275710 2009-01-21 00:07 movie.avi
$ ffmpeg -i "movie.mpg" -vcodec mpeg4 movie.avi 2> ./ffmpeg.log
$ ls -l
-rw-r--r-- 1 colucix users 6413 2009-01-21 00:08 ffmpeg.log
-rw-r--r-- 1 colucix users 58653112 2008-12-28 21:53 movie.mpg
-rw-r--r-- 1 colucix users 13275710 2009-01-21 00:09 movie.avi
As you can see if I redirect just the standard output (first ffmpeg command), the messages appear on the screen but not in the log file. If I redirect just the standard error (second ffmpeg command) nothing is displayed on the screen and the output goes to the log file. To me this demonstrates that ffmpeg writes to standard error and if you redirect it to /dev/null you will not get any message.
You can also investigate on the -passlogfile option of ffmpeg to see if it is useful for your issue.
|
|
|
01-20-2009, 05:37 PM
|
#5
|
Member
Registered: Jan 2009
Location: Stockholm Sweden
Distribution: Ubuntu 9.10
Posts: 57
Original Poster
Rep:
|
I know all these stuff man. have you tried the command which I posted above. Then you understand what I am trying to say. The command which I posted above displayed generates a SDP information If I dont redirect the 1 to File it displays to stdout. I need this information so I redirect to a file. Then I have to delete one line from this File, but I am unable to do so.
|
|
|
01-20-2009, 05:43 PM
|
#6
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
Ok. It's clear now. I just didn't know the rtp:// protocol. Sorry.
|
|
|
01-20-2009, 05:47 PM
|
#7
|
Member
Registered: Jan 2009
Location: Stockholm Sweden
Distribution: Ubuntu 9.10
Posts: 57
Original Poster
Rep:
|
Thanks for all your help.
Hope some one knows the answer of my question. 
|
|
|
01-20-2009, 06:18 PM
|
#8
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
Here I am again! I will be your nightmare... just for the next couple of minutes!  Seriously, to me since you launch the ffmpeg command in background, the head/tail command is executed immediately after, so that the ffmpeg command has not the time to populate the /tmp/tmp_sdp file. Take in mind that when you issue a redirection the output file is immediately created and has 0 size. Solution: insert a sleep 5 between the ffmpeg line and the head/tail line.
|
|
|
01-20-2009, 07:02 PM
|
#9
|
Member
Registered: Jan 2009
Location: Stockholm Sweden
Distribution: Ubuntu 9.10
Posts: 57
Original Poster
Rep:
|
Thanks a lot Man.
now I got your point. Its working now.
Thank you very much
|
|
|
All times are GMT -5. The time now is 05:33 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|