LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 01-20-2009, 04:39 PM   #1
waqasdaar
Member
 
Registered: Jan 2009
Location: Stockholm Sweden
Distribution: Ubuntu 9.10
Posts: 57

Rep: Reputation: 15
Question 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
 
Old 01-20-2009, 04:45 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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?
 
Old 01-20-2009, 04:57 PM   #3
waqasdaar
Member
 
Registered: Jan 2009
Location: Stockholm Sweden
Distribution: Ubuntu 9.10
Posts: 57

Original Poster
Rep: Reputation: 15
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.
 
Old 01-20-2009, 05:17 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
Old 01-20-2009, 05:37 PM   #5
waqasdaar
Member
 
Registered: Jan 2009
Location: Stockholm Sweden
Distribution: Ubuntu 9.10
Posts: 57

Original Poster
Rep: Reputation: 15
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.
 
Old 01-20-2009, 05:43 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Ok. It's clear now. I just didn't know the rtp:// protocol. Sorry.
 
Old 01-20-2009, 05:47 PM   #7
waqasdaar
Member
 
Registered: Jan 2009
Location: Stockholm Sweden
Distribution: Ubuntu 9.10
Posts: 57

Original Poster
Rep: Reputation: 15
Thanks for all your help.
Hope some one knows the answer of my question.
 
Old 01-20-2009, 06:18 PM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
Old 01-20-2009, 07:02 PM   #9
waqasdaar
Member
 
Registered: Jan 2009
Location: Stockholm Sweden
Distribution: Ubuntu 9.10
Posts: 57

Original Poster
Rep: Reputation: 15
Thanks a lot Man.
now I got your point. Its working now.
Thank you very much
 
  


Reply

Tags
ffmpeg


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me in installing ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encod mitesh.ever Red Hat 5 05-16-2009 12:14 PM
ffmpeg to convert QuickTime mov-file into dv file arkadig Linux - Software 1 04-16-2008 09:31 AM
svn ffmpeg: No man file?? andrew.46 Slackware 6 02-23-2008 06:04 PM
Getting File Information With ffmpeg wenberg Linux - Software 1 11-23-2007 03:05 AM
Store each line in a different file onradius Programming 7 02-21-2006 11:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration