Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ffworker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Video AG Infrastruktur
ffworker
Commits
cf956eb7
Commit
cf956eb7
authored
1 year ago
by
Dorian Koch
Browse files
Options
Downloads
Patches
Plain Diff
Fix deprecated ffmpeg library calls
parent
c0f9aafe
No related branches found
No related tags found
No related merge requests found
Pipeline
#5703
failed
1 year ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
transcode.c
+27
-21
27 additions, 21 deletions
transcode.c
with
27 additions
and
21 deletions
transcode.c
+
27
−
21
View file @
cf956eb7
...
@@ -77,7 +77,7 @@ static void setup_input_stream(char *stream, AVFormatContext *demux,
...
@@ -77,7 +77,7 @@ static void setup_input_stream(char *stream, AVFormatContext *demux,
p
=
mprintf
(
"time_base=%d/%d:sample_rate=%d:sample_fmt=%d:channel_layout=%s:channels=%d"
,
p
=
mprintf
(
"time_base=%d/%d:sample_rate=%d:sample_fmt=%d:channel_layout=%s:channels=%d"
,
demux
->
streams
[
idx
]
->
time_base
.
num
,
demux
->
streams
[
idx
]
->
time_base
.
den
,
demux
->
streams
[
idx
]
->
time_base
.
num
,
demux
->
streams
[
idx
]
->
time_base
.
den
,
decs
[
idx
]
->
sample_rate
,
decs
[
idx
]
->
sample_fmt
,
ch_layout
,
decs
[
idx
]
->
sample_rate
,
decs
[
idx
]
->
sample_fmt
,
ch_layout
,
decs
[
idx
]
->
channels
);
decs
[
idx
]
->
ch_layout
.
nb_
channels
);
err
=
avfilter_graph_create_filter
(
&
srcs
[
idx
],
err
=
avfilter_graph_create_filter
(
&
srcs
[
idx
],
avfilter_get_by_name
(
"abuffer"
),
0
,
p
,
0
,
fg
);
avfilter_get_by_name
(
"abuffer"
),
0
,
p
,
0
,
fg
);
if
(
err
<
0
)
if
(
err
<
0
)
...
@@ -135,8 +135,16 @@ static void prepare_output_stream(char *stream, AVStream *st,
...
@@ -135,8 +135,16 @@ static void prepare_output_stream(char *stream, AVStream *st,
AV_SAMPLE_FMT_NONE
,
AV_OPT_SEARCH_CHILDREN
);
AV_SAMPLE_FMT_NONE
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int_list
(
sinks
[
idx
],
"sample_rates"
,
av_opt_set_int_list
(
sinks
[
idx
],
"sample_rates"
,
encs
[
idx
]
->
codec
->
supported_samplerates
,
0
,
AV_OPT_SEARCH_CHILDREN
);
encs
[
idx
]
->
codec
->
supported_samplerates
,
0
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int_list
(
sinks
[
idx
],
"channel_layouts"
,
encs
[
idx
]
->
codec
->
channel_layouts
,
0
,
AV_OPT_SEARCH_CHILDREN
);
// find length of ch_layouts
int
ch_layouts_len
=
0
;
for
(
int
i
=
0
;
encs
[
idx
]
->
codec
->
ch_layouts
&&
encs
[
idx
]
->
codec
->
ch_layouts
[
i
].
nb_channels
;
i
++
)
ch_layouts_len
++
;
if
(
ch_layouts_len
>
0
)
{
av_opt_set_bin
(
sinks
[
idx
],
"ch_layouts"
,
(
const
uint8_t
*
)
encs
[
idx
]
->
codec
->
ch_layouts
,
ch_layouts_len
,
AV_OPT_SEARCH_CHILDREN
);
}
// not setting ch_layouts equals to setting all possible layouts
}
}
else
else
job_failed
(
"Requested codec has unsupported type
\n
"
);
job_failed
(
"Requested codec has unsupported type
\n
"
);
...
@@ -174,8 +182,8 @@ static void setup_output_stream(char *stream, AVStream *st, AVCodecContext *enc,
...
@@ -174,8 +182,8 @@ static void setup_output_stream(char *stream, AVStream *st, AVCodecContext *enc,
else
if
(
enc
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
else
if
(
enc
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
{
{
enc
->
sample_rate
=
av_buffersink_get_sample_rate
(
sink
);
enc
->
sample_rate
=
av_buffersink_get_sample_rate
(
sink
);
enc
->
channel_layout
=
av_buffersink_get_ch
annel
_layout
(
sink
)
;
if
((
err
=
av_buffersink_get_ch_layout
(
sink
,
&
enc
->
ch_layout
))
<
0
)
enc
->
channels
=
av_buffersink_get_channels
(
sink
);
job_failed
(
"Could not get channel layout: %s"
,
av_err2str
(
err
)
);
enc
->
sample_fmt
=
av_buffersink_get_format
(
sink
);
enc
->
sample_fmt
=
av_buffersink_get_format
(
sink
);
}
}
enc
->
time_base
=
av_buffersink_get_time_base
(
sink
);
enc
->
time_base
=
av_buffersink_get_time_base
(
sink
);
...
@@ -193,18 +201,16 @@ static void setup_output_stream(char *stream, AVStream *st, AVCodecContext *enc,
...
@@ -193,18 +201,16 @@ static void setup_output_stream(char *stream, AVStream *st, AVCodecContext *enc,
static
void
flush_encoder
(
AVFormatContext
*
mux
,
AVFilterContext
*
sink
,
AVCodecContext
*
enc
,
int
idx
)
static
void
flush_encoder
(
AVFormatContext
*
mux
,
AVFilterContext
*
sink
,
AVCodecContext
*
enc
,
int
idx
)
{
{
int
err
;
int
err
;
AVPacket
pkt
;
AVPacket
*
pkt
=
av_packet_alloc
();
pkt
.
data
=
0
;
while
(
!
avcodec_receive_packet
(
enc
,
pkt
))
pkt
.
size
=
0
;
av_init_packet
(
&
pkt
);
while
(
!
avcodec_receive_packet
(
enc
,
&
pkt
))
{
{
pkt
.
stream_index
=
idx
;
pkt
->
stream_index
=
idx
;
av_packet_rescale_ts
(
&
pkt
,
enc
->
time_base
,
av_packet_rescale_ts
(
pkt
,
enc
->
time_base
,
mux
->
streams
[
idx
]
->
time_base
);
mux
->
streams
[
idx
]
->
time_base
);
if
(
err
=
av_interleaved_write_frame
(
mux
,
&
pkt
))
if
(
err
=
av_interleaved_write_frame
(
mux
,
pkt
))
job_failed
(
"Could not write frame: %s"
,
av_err2str
(
err
));
job_failed
(
"Could not write frame: %s"
,
av_err2str
(
err
));
}
}
av_packet_free
(
&
pkt
);
}
}
static
void
flush_filtergraph
(
AVFormatContext
*
mux
,
AVFilterContext
**
sinks
,
AVCodecContext
**
encs
)
static
void
flush_filtergraph
(
AVFormatContext
*
mux
,
AVFilterContext
**
sinks
,
AVCodecContext
**
encs
)
...
@@ -267,7 +273,7 @@ int main(int argc, char *argv[])
...
@@ -267,7 +273,7 @@ int main(int argc, char *argv[])
AVFilterContext
**
srcs
,
**
sinks
;
AVFilterContext
**
srcs
,
**
sinks
;
AVFilterGraph
*
fg
;
AVFilterGraph
*
fg
;
AVFilterInOut
*
inpads
,
*
outpads
;
AVFilterInOut
*
inpads
,
*
outpads
;
AVPacket
pkt
;
AVPacket
*
pkt
;
AVStream
*
stream
;
AVStream
*
stream
;
AVDictionary
*
opts
;
AVDictionary
*
opts
;
if
(
argc
!=
5
)
if
(
argc
!=
5
)
...
@@ -275,9 +281,6 @@ int main(int argc, char *argv[])
...
@@ -275,9 +281,6 @@ int main(int argc, char *argv[])
init_env
();
init_env
();
umask
(
S_IWOTH
);
umask
(
S_IWOTH
);
init_avlogbuf
();
init_avlogbuf
();
pkt
.
data
=
0
;
pkt
.
size
=
0
;
av_init_packet
(
&
pkt
);
if
(
!
(
fg
=
avfilter_graph_alloc
()))
if
(
!
(
fg
=
avfilter_graph_alloc
()))
return
99
;
return
99
;
...
@@ -343,10 +346,11 @@ int main(int argc, char *argv[])
...
@@ -343,10 +346,11 @@ int main(int argc, char *argv[])
progress
=
0
;
progress
=
0
;
ping_job
(
jobid
,
"running"
,
0
);
ping_job
(
jobid
,
"running"
,
0
);
while
(
!
av_read_frame
(
demux
,
&
pkt
))
pkt
=
av_packet_alloc
();
while
(
!
av_read_frame
(
demux
,
pkt
))
{
{
i
=
pkt
.
stream_index
;
i
=
pkt
->
stream_index
;
_progress
=
av_rescale_q
(
pkt
.
pts
,
demux
->
streams
[
i
]
->
time_base
,
AV_TIME_BASE_Q
)
*
100
/
demux
->
duration
;
_progress
=
av_rescale_q
(
pkt
->
pts
,
demux
->
streams
[
i
]
->
time_base
,
AV_TIME_BASE_Q
)
*
100
/
demux
->
duration
;
if
(
_progress
>
progress
||
!
checktime
(
30
))
if
(
_progress
>
progress
||
!
checktime
(
30
))
{
{
canceled
=
ping_job
(
jobid
,
"running"
,
"{
\"
progress
\"
: %i,
\"
log
\"
:
\"
%s
\"
}"
,
_progress
,
canceled
=
ping_job
(
jobid
,
"running"
,
"{
\"
progress
\"
: %i,
\"
log
\"
:
\"
%s
\"
}"
,
_progress
,
...
@@ -355,9 +359,11 @@ int main(int argc, char *argv[])
...
@@ -355,9 +359,11 @@ int main(int argc, char *argv[])
job_failed
(
"Job canceled"
);
job_failed
(
"Job canceled"
);
progress
=
_progress
;
progress
=
_progress
;
}
}
filtergraph_send
(
srcs
[
i
],
decs
[
i
],
&
pkt
);
filtergraph_send
(
srcs
[
i
],
decs
[
i
],
pkt
);
flush_filtergraph
(
mux
,
sinks
,
encs
);
flush_filtergraph
(
mux
,
sinks
,
encs
);
av_packet_unref
(
pkt
);
}
}
av_packet_free
(
&
pkt
);
/* Flush */
/* Flush */
for
(
i
=
0
;
i
<
demux
->
nb_streams
;
i
++
)
for
(
i
=
0
;
i
<
demux
->
nb_streams
;
i
++
)
...
...
This diff is collapsed.
Click to expand it.
Dorian Koch
@doriank
mentioned in commit
6a250110
·
1 year ago
mentioned in commit
6a250110
mentioned in commit 6a25011042e350b7f2022a1c962fce67af699cc2
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment