Skip to content

Commit 73c5988

Browse files
expose streaming parameters on tutorial
1 parent 1074077 commit 73c5988

1 file changed

Lines changed: 69 additions & 1 deletion

File tree

README.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,74 @@ int encode(AVFormatContext *avfc, AVStream *dec_video_avs, AVStream *enc_video_a
879879
880880
```
881881

882-
We converted the media stream from `h264` to `h265`, as expected the `h265` version of the media file is smaller than the `h264`.
882+
We converted the media stream from `h264` to `h265`, as expected the `h265` version of the media file is smaller than the `h264` however the [created program](/3_transcoding.c) is capable of:
883+
884+
```c
885+
886+
/*
887+
* H264 -> H265
888+
* Audio -> remuxed (untouched)
889+
* MP4 - MP4
890+
*/
891+
StreamingParams sp = {0};
892+
sp.copy_audio = 1;
893+
sp.copy_video = 0;
894+
sp.video_codec = "libx265";
895+
sp.codec_priv_key = "x265-params";
896+
sp.codec_priv_value = "keyint=60:min-keyint=60:scenecut=0";
897+
898+
/*
899+
* H264 -> H264 (fixed gop)
900+
* Audio -> remuxed (untouched)
901+
* MP4 - MP4
902+
*/
903+
StreamingParams sp = {0};
904+
sp.copy_audio = 1;
905+
sp.copy_video = 0;
906+
sp.video_codec = "libx264";
907+
sp.codec_priv_key = "x264-params";
908+
sp.codec_priv_value = "keyint=60:min-keyint=60:scenecut=0:force-cfr=1";
909+
910+
/*
911+
* H264 -> H264 (fixed gop)
912+
* Audio -> remuxed (untouched)
913+
* MP4 - fragmented MP4
914+
*/
915+
StreamingParams sp = {0};
916+
sp.copy_audio = 1;
917+
sp.copy_video = 0;
918+
sp.video_codec = "libx264";
919+
sp.codec_priv_key = "x264-params";
920+
sp.codec_priv_value = "keyint=60:min-keyint=60:scenecut=0:force-cfr=1";
921+
sp.muxer_opt_key = "movflags";
922+
sp.muxer_opt_value = "frag_keyframe+empty_moov+default_base_moof";
923+
924+
/*
925+
* H264 -> H264 (fixed gop)
926+
* Audio -> AAC
927+
* MP4 - MPEG-TS
928+
*/
929+
StreamingParams sp = {0};
930+
sp.copy_audio = 0;
931+
sp.copy_video = 0;
932+
sp.video_codec = "libx264";
933+
sp.codec_priv_key = "x264-params";
934+
sp.codec_priv_value = "keyint=60:min-keyint=60:scenecut=0:force-cfr=1";
935+
sp.audio_codec = "aac";
936+
sp.output_extension = ".ts";
937+
938+
/* WIP :P -> it's not playing on VLC, the final bit rate is huge
939+
* H264 -> VP9
940+
* Audio -> Vorbis
941+
* MP4 - WebM
942+
*/
943+
//StreamingParams sp = {0};
944+
//sp.copy_audio = 0;
945+
//sp.copy_video = 0;
946+
//sp.video_codec = "libvpx-vp9";
947+
//sp.audio_codec = "libvorbis";
948+
//sp.output_extension = ".webm";
949+
950+
```
883951
884952
> Now, to be honest, this was [harder than I thought](https://github.com/leandromoreira/ffmpeg-libav-tutorial/pull/54) it'd be and I had to dig into the [FFmpeg command line source code](https://github.com/leandromoreira/ffmpeg-libav-tutorial/pull/54#issuecomment-570746749) and test it a lot and I think I'm missing something because I had to enforce `force-cfr` for the `h264` to work and I'm still seeing some warning messages like `warning messages (forced frame type (5) at 80 was changed to frame type (3))`.

0 commit comments

Comments
 (0)