[Libav-user] Remuxing video file
Yuri Oleynikov (יורי אולייניקוב
yurkao at gmail.com
Sat Feb 1 22:47:38 CET 2014
hello, i am new to libav. after reading documentation and examples for
serveral weeks, i tried to write simple remuxing (e.g mp4->avi) w/o
decoding/encoding, just like *ffmpeg -i inputfile.mp4 -f avi -c:v copy -an
output.avi.*
however both VLC and windows media player refuse to play output avi file -
no video playback.
moreoever ffprobe on output file shows me incorrect duration and bitrate.
moreover, though the output file contains only video streams and lacks
audio streams it's much bigger than the input file:
-rw-r--r-- 1 me me 28689538 Feb 1 13:00 inputk.mp4
-rw-r--r-- 1 me me 77916554 Feb 1 13:40 output.avi
i am definitely missing somesthing.
again, my appologies, i'm a new to libav*. :(
thanks for help.
PS: sorry for long mail.
my shortened code:
avformat_open_input(&ic, infname, NULL, NULL);
avformat_find_stream_info(ic, NULL);
oc = avformat_alloc_context();
oc->oformat = av_guess_format("avi", NULL, NULL);
/**no need to open encoders/decoders since i do no want to recode the
frames) **/
memmove(oc->filename, outfname, strlen(outfname));
avio_open(&oc->pb, outfname, AVIO_FLAG_WRITE);
// stripped map input video streams to output video streams block
avformat_write_header(oc, NULL);
for(i=0; av_read_frame(ic, &inpacket)>=0; i++, av_free_packet(&inpacket)) {
idx = inpacket.stream_index;
stream = ic->streams[idx];
if(stream_map[idx]==-1){
continue;
}
if(ic->streams[stream_map[idx]]->codec->codec_type!=AVMEDIA_TYPE_VIDEO)
continue;
av_copy_packet(&outpacket, &inpacket);
outpacket.stream_index = stream_map[idx];
av_interleaved_write_frame(oc, &outpacket);
av_free_packet(&outpacket);
}
av_write_trailer(oc);
my full code: https://github.com/yurkao/libavformat-test/blob/master/remux.c
ffprobe original.mp4
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'original.mp4':
> Metadata:
> major_brand : mp42
> minor_version : 1
> compatible_brands: isommp41avc1
> creation_time : 2011-05-05 18:09:35
> Duration: 00:01:10.04, start: 0.000000, bitrate: 3277 kb/s
> Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661),
yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 3150 kb/s, 29.96 fps, 29.96 tbr,
29956 tbn, 59.92 tbc (default)
> Metadata:
> creation_time : 2011-05-05 18:09:35
> handler_name : ?Apple Video Media Handler
> Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo,
fltp, 123 kb/s (default)
> Metadata:
> creation_time : 2011-05-05 18:09:35
> handler_name : ?Apple Sound Media Handler
> Stream #0:2(eng): Data: none (mp4s / 0x7334706D), 0 kb/s (default)
> Metadata:
> creation_time : 2011-05-05 18:09:35
> handler_name : ?
> Stream #0:3(eng): Data: none (mp4s / 0x7334706D), 0 kb/s (default)
> Metadata:
> creation_time : 2011-05-05 18:09:35
> handler_name : ?
ffprobe output.avi
> Input #0, avi, from 'output.avi':
> Metadata:
> encoder : Lavf55.19.104
> Duration: 09:43:16.62, start: 0.000000, bitrate: 17 kb/s
> Stream #0:0: Video: h264 (Main) (H264 / 0x34363248), yuv420p(tv),
1280x720 [SAR 1:1 DAR 16:9], 59.92 fps, 0.06 tbr, 59.92 tbn, 59.92 tbc
Linux ffmpeg libs:
Version: 2.1.3
OS: Ubuntu 12.04.3 LTS amd64
compiler: gcc 4.6.3
> --disable-doc --enable-shared --disable-network --enable-gpl
--enable-nonfree --enable-libmp3lame --enable-libx264 --enable-libvorbis
--enable-libtheora --enable-libspeex --enable-libvpx --enable-libfaac
--enable-libopenjpeg --disable-ffserver --enable-postproc
--disable-w32threads --disable-os2threads --disable-indevs
--disable-outdevs --disable-avdevice --disable-x11grab --enable-pic
--enable-zlib --enable-bzlib --enable-shared --enable-avresample
--enable-swscale --enable-swresample --enable-postproc --enable-avfilter
--enable-avformat --enable-avcodec --enable-avutil
Windows ffmpeg libs:
Version: ffmpeg-20140121-git-13e0109-win32-shared
OS: Windows 7 64 bit
compiler: VS 2010 target 32bit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20140201/b3d57915/attachment.html>
More information about the Libav-user
mailing list