--- On Wed, 5/5/10, Ferenc Deak <[email protected]> wrote:

> From: Ferenc Deak <[email protected]>
> Subject: Re: [libav-user] Movie cutting problems
> To: "Libav* user questions and discussions" <[email protected]>
> Date: Wednesday, May 5, 2010, 4:09 AM
> Hi,
> 
> mine is at:
> 
> http://dev.adactus.no:10080/moviecutter/
> 
> maybe someone will see the bug (please use only with mp4
> files). I'm 
> pretty sure that something is messed up in the way I'm
> handling (or NOT 
> handling) the global header for the mp4 file.
> 
> BTW I could'nt compile yours, make output:
> 
> fer...@dfl:~/work/sdrlive_src> make
> cc -c -o main.o main.c
> main.c: In function ‘main’:
> main.c:78: warning: assignment makes pointer from integer
> without a cast
> cc -c -o ffmpeg_ripoff.o ffmpeg_ripoff.c
> gcc -o sdrlive main.o ffmpeg_ripoff.o -lavformat -lavcodec
> -lz
> main.o: In function `main':
> main.c:(.text+0x25e): undefined reference to
> `av_guess_format'
> collect2: ld returned 1 exit status
> make: *** [sdrlive] Error 1
> 
> Thanks,
> Frc
> 
> 
> On 05/05/2010 09:36 AM, Stoian Ivanov wrote:
> > On Wed, Apr 28, 2010 at 1:45 PM, Ferenc Deak<[email protected]> 
> wrote:
> >    
> >> Hi all,
> >>
> >> I have the following situation here: I need to
> implement a small tool which
> >> cuts the first X (10 or 20, 30, ...) seconds out
> of a movie clip, and writes
> >> the result in a new file.
> >>
> >> What I do is very similar to the
> initialization/opening phase from ffplay.c:
> >>
> >> 1. Open the file (av_open_input_file,
> av_find_stream_info)
> >> 2. Seek to the required position
> (avformat_seek_file)
> >> 3. Setup the codecs (including check for global
> headers
> >> 4. Create an output context (AVFormatContext based
> on AVOutputFormat)
> >> 5. Open the output file (url_fopen)
> >> 6. Write the output header
> >> 7. loop starts: read a packet from the input file
> (av_read_frame)
> >> 8. modify the packet's time to be zero based (PTS,
> DTS)
> >> 9. write the packet to the output
> >> 10. go to 7 if we have more packets to read
> >> 11. write_trailer, close the files.
> >> 12. done
> >>
> >> Now, here comes the problem. It has a small "bug"
> (probably in the logic) :
> >> after the app runs and "cuts" the file it seems
> that the players don't see
> >> the video stream anymore, so they display the
> first video frame and after
> >> this only the audio is being played. I have
> included a small logger, and if
> >> I run my cutter application once more, it sees
> only the audio frames... In
> >> ffplay I open the file and it plays the audio
> nicely, the first video frame
> >> is frozen on the screen, but if I click somewhere
> on the ffplay window
> >> (meaning: seek) it seeks there, starts playing the
> video only. NO audio
> >> frames are there anymore ... Step 8 is not
> responsible for this stupid
> >> behavior, it behaves the same way if it's there or
> not.
> >>
> >> Have you ever seen this behavior? Had anyone of
> you implemented this cut out
> >> feature?
> >>
> >> Thanks
> >> Ferenc
> >>
> >>      
> > I got similar task but totally different problems - i
> loose the audio
> > :( and the file doubles it's size. If interested my
> code is at
> >
> > http://sdr.tera-com.com/tmp/sdrlive_src.tar.bz2
> >
> >   and I'm much interested in yours
> > _______________________________________________
> > libav-user mailing list
> > [email protected]
> > https://lists.mplayerhq.hu/mailman/listinfo/libav-user
> >    
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
> 

You can also use av_dup_packet(&packet); (line 241). Not sure if this is the 
reason but it doesn't hurt to use it.

More important instead of 'av_write_frame' you should use 
av_interleaved_write_frame.

Except these 2 the code looks pretty much like mine.


      
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to