Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Using ffmpeg to demux an h264 stream from a .flv video always gives me a stream which I cannot remux into a .mp4 container (using either MP4Box from package *gpac), or ffmpeg).

Here is the demuxing command which produces the "invalid" stream.. (Unknown format)

ffmpeg -i "(h264-aac).flv"  # get stream info
  # Stream #0.0: Video: h264, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 259 kb/s, 29.97 tbr, 1k tbn, 59.94 tbc

ffmpeg -y -map "0.0" -vcodec copy -an -i "(h264-aac).flv" \
                                         "(h264-aac).flv.h264" 

I've also tried it with: -f h264, but get the same error.

The above command works when run against a video in a .mp4 container, so maybe this is something specific to flv(?).

The closest I've come to isolating the h264 video stream is with the following command; but it wraps the stream in an flv container which has lost its aspect ratio....

ffmpeg -y -map "0.0" -vcodec copy -an -i "(h264-aac).flv" \
                                         "(h264-aac).flv.NEW.flv" 

Is there some way to grab this video stream?

PS. I've treid with several different input .flv vids, ...same error.

share|improve this question
add comment

1 Answer

What is the purpose of the intermediate step wherein you store the raw H.264 stream as an uncontainered file before you ultimately mux it into an .mp4 container?

Sure, a raw mpeg2 video stream or .aac audio track can be stored without container overhead, but as you have come to realise, the obvious candidates for app-friendly file extensions-- .avc, .h264, .ts-- don't seem make a raw H.264 stream any easier for FFmpeg or VLC to manipulate.

If your H.264 stream is destined to end up in an .mp4 container, why not copy the video stream directly from your .flv file into an .mp4 fle and store it there until you're ready to mux audio into the final product?

The command line would look something like this:

  ffmpeg -i infile.flv -an -vcodec copy outfile.mp4

If FFmpeg throws error messages in response to this simple command line, you might actually have a corrupt file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.